Cheetah
ValidatorAtom.php
Go to the documentation of this file.
1 <?php
2 
10 {
14  protected $context;
15 
19  protected $obj;
20 
24  protected $member;
25 
29  protected $contents;
30 
31  public function __construct($context, $obj, $member)
32  {
33  $this->context = $context;
34  $this->obj = $obj;
35  $this->member = $member;
36  $this->contents =& $obj->$member;
37  }
38 
42  public function assertIsString()
43  {
44  if (!is_string($this->contents)) {
45  $this->error('must be a string');
46  }
47  return $this;
48  }
49 
53  public function assertIsBool()
54  {
55  if (!is_bool($this->contents)) {
56  $this->error('must be a boolean');
57  }
58  return $this;
59  }
60 
64  public function assertIsArray()
65  {
66  if (!is_array($this->contents)) {
67  $this->error('must be an array');
68  }
69  return $this;
70  }
71 
75  public function assertNotNull()
76  {
77  if ($this->contents === null) {
78  $this->error('must not be null');
79  }
80  return $this;
81  }
82 
86  public function assertAlnum()
87  {
88  $this->assertIsString();
89  if (!ctype_alnum($this->contents)) {
90  $this->error('must be alphanumeric');
91  }
92  return $this;
93  }
94 
98  public function assertNotEmpty()
99  {
100  if (empty($this->contents)) {
101  $this->error('must not be empty');
102  }
103  return $this;
104  }
105 
109  public function assertIsLookup()
110  {
111  $this->assertIsArray();
112  foreach ($this->contents as $v) {
113  if ($v !== true) {
114  $this->error('must be a lookup array');
115  }
116  }
117  return $this;
118  }
119 
124  protected function error($msg)
125  {
126  throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member) . ' in ' . $this->context . ' ' . $msg);
127  }
128 }
129 
130 // vim: et sw=4 sts=4
HTMLPurifier_ConfigSchema_ValidatorAtom\$member
$member
Definition: ValidatorAtom.php:24
HTMLPurifier_ConfigSchema_ValidatorAtom\assertIsString
assertIsString()
Definition: ValidatorAtom.php:42
HTMLPurifier_ConfigSchema_ValidatorAtom\error
error($msg)
Definition: ValidatorAtom.php:124
HTMLPurifier_ConfigSchema_Exception
Definition: Exception.php:7
HTMLPurifier_ConfigSchema_ValidatorAtom\assertNotNull
assertNotNull()
Definition: ValidatorAtom.php:75
php
context
you may still notice some empty particularly if a node had but those elements were later removed because they were not permitted in that context
Definition: AutoFormat.RemoveEmpty.txt:40
HTMLPurifier_ConfigSchema_ValidatorAtom\assertIsArray
assertIsArray()
Definition: ValidatorAtom.php:64
contents
License THE YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS Definitions Adaptation means a work based upon the or upon the Work and other pre existing such as a derivative arrangement of music or other alterations of a literary or artistic or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be or adapted including in any form recognizably derived from the except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License For the avoidance of where the Work is a musical performance or the synchronization of the Work in timed relation with a moving such as encyclopedias and or phonograms or or other works or subject matter other than works listed in by reason of the selection and arrangement of their contents
Definition: license.txt:15
HTMLPurifier_ConfigSchema_ValidatorAtom\$obj
$obj
Definition: ValidatorAtom.php:19
HTMLPurifier_ConfigSchema_ValidatorAtom\assertAlnum
assertAlnum()
Definition: ValidatorAtom.php:86
HTMLPurifier_ConfigSchema_ValidatorAtom\assertIsLookup
assertIsLookup()
Definition: ValidatorAtom.php:109
HTMLPurifier_ConfigSchema_ValidatorAtom\$context
$context
Definition: ValidatorAtom.php:14
HTMLPurifier_ConfigSchema_ValidatorAtom\$contents
$contents
Definition: ValidatorAtom.php:29
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
HTMLPurifier_ConfigSchema_ValidatorAtom\assertNotEmpty
assertNotEmpty()
Definition: ValidatorAtom.php:98
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
HTMLPurifier_ConfigSchema_ValidatorAtom
Definition: ValidatorAtom.php:10
HTMLPurifier_ConfigSchema_ValidatorAtom\assertIsBool
assertIsBool()
Definition: ValidatorAtom.php:53
HTMLPurifier_ConfigSchema_ValidatorAtom\__construct
__construct($context, $obj, $member)
Definition: ValidatorAtom.php:31