ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
HTMLPurifier_ConfigSchema_ValidatorAtom Class Reference

Fluent interface for validating the contents of member variables. More...

+ Collaboration diagram for HTMLPurifier_ConfigSchema_ValidatorAtom:

Public Member Functions

 __construct ($context, $obj, $member)
 
 assertIsString ()
 
 assertIsBool ()
 
 assertIsArray ()
 
 assertNotNull ()
 
 assertAlnum ()
 
 assertNotEmpty ()
 
 assertIsLookup ()
 

Protected Member Functions

 error ($msg)
 

Protected Attributes

 $context
 string More...
 
 $obj
 object More...
 
 $member
 string More...
 
 $contents
 mixed More...
 

Detailed Description

Fluent interface for validating the contents of member variables.

This should be immutable. See HTMLPurifier_ConfigSchema_Validator for use-cases. We name this an 'atom' because it's ONLY for validations that are independent and usually scalar.

Definition at line 9 of file ValidatorAtom.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_ConfigSchema_ValidatorAtom::__construct (   $context,
  $obj,
  $member 
)

Definition at line 31 of file ValidatorAtom.php.

References $context, $member, and $obj.

32  {
33  $this->context = $context;
34  $this->obj = $obj;
35  $this->member = $member;
36  $this->contents =& $obj->$member;
37  }

Member Function Documentation

◆ assertAlnum()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertAlnum ( )
Returns
HTMLPurifier_ConfigSchema_ValidatorAtom

Definition at line 86 of file ValidatorAtom.php.

References assertIsString(), and error().

87  {
88  $this->assertIsString();
89  if (!ctype_alnum($this->contents)) {
90  $this->error('must be alphanumeric');
91  }
92  return $this;
93  }
+ Here is the call graph for this function:

◆ assertIsArray()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertIsArray ( )
Returns
HTMLPurifier_ConfigSchema_ValidatorAtom

Definition at line 64 of file ValidatorAtom.php.

References error().

Referenced by assertIsLookup().

65  {
66  if (!is_array($this->contents)) {
67  $this->error('must be an array');
68  }
69  return $this;
70  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assertIsBool()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertIsBool ( )
Returns
HTMLPurifier_ConfigSchema_ValidatorAtom

Definition at line 53 of file ValidatorAtom.php.

References error().

54  {
55  if (!is_bool($this->contents)) {
56  $this->error('must be a boolean');
57  }
58  return $this;
59  }
+ Here is the call graph for this function:

◆ assertIsLookup()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertIsLookup ( )
Returns
HTMLPurifier_ConfigSchema_ValidatorAtom

Definition at line 109 of file ValidatorAtom.php.

References assertIsArray(), and error().

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  }
+ Here is the call graph for this function:

◆ assertIsString()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertIsString ( )
Returns
HTMLPurifier_ConfigSchema_ValidatorAtom

Definition at line 42 of file ValidatorAtom.php.

References error().

Referenced by assertAlnum().

43  {
44  if (!is_string($this->contents)) {
45  $this->error('must be a string');
46  }
47  return $this;
48  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assertNotEmpty()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertNotEmpty ( )
Returns
HTMLPurifier_ConfigSchema_ValidatorAtom

Definition at line 98 of file ValidatorAtom.php.

References error().

99  {
100  if (empty($this->contents)) {
101  $this->error('must not be empty');
102  }
103  return $this;
104  }
+ Here is the call graph for this function:

◆ assertNotNull()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertNotNull ( )
Returns
HTMLPurifier_ConfigSchema_ValidatorAtom

Definition at line 75 of file ValidatorAtom.php.

References error().

76  {
77  if ($this->contents === null) {
78  $this->error('must not be null');
79  }
80  return $this;
81  }
+ Here is the call graph for this function:

◆ error()

HTMLPurifier_ConfigSchema_ValidatorAtom::error (   $msg)
protected
Parameters
string$msg
Exceptions
HTMLPurifier_ConfigSchema_Exception

Definition at line 124 of file ValidatorAtom.php.

Referenced by assertAlnum(), assertIsArray(), assertIsBool(), assertIsLookup(), assertIsString(), assertNotEmpty(), and assertNotNull().

125  {
126  throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member) . ' in ' . $this->context . ' ' . $msg);
127  }
Exceptions related to configuration schema.
Definition: Exception.php:6
+ Here is the caller graph for this function:

Field Documentation

◆ $contents

HTMLPurifier_ConfigSchema_ValidatorAtom::$contents
protected

mixed

Definition at line 29 of file ValidatorAtom.php.

◆ $context

HTMLPurifier_ConfigSchema_ValidatorAtom::$context
protected

string

Definition at line 14 of file ValidatorAtom.php.

Referenced by __construct().

◆ $member

HTMLPurifier_ConfigSchema_ValidatorAtom::$member
protected

string

Definition at line 24 of file ValidatorAtom.php.

Referenced by __construct().

◆ $obj

HTMLPurifier_ConfigSchema_ValidatorAtom::$obj
protected

object

Definition at line 19 of file ValidatorAtom.php.

Referenced by __construct().


The documentation for this class was generated from the following file: