ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
 @type string More...
 
 $obj
 @type object More...
 
 $member
 @type string More...
 
 $contents
 @type 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.

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

References $context, $member, and $obj.

Member Function Documentation

◆ assertAlnum()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertAlnum ( )
Returns
HTMLPurifier_ConfigSchema_ValidatorAtom

Definition at line 86 of file ValidatorAtom.php.

87 {
88 $this->assertIsString();
89 if (!ctype_alnum($this->contents)) {
90 $this->error('must be alphanumeric');
91 }
92 return $this;
93 }

References assertIsString(), and error().

+ 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.

65 {
66 if (!is_array($this->contents)) {
67 $this->error('must be an array');
68 }
69 return $this;
70 }

References error().

Referenced by assertIsLookup().

+ 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.

54 {
55 if (!is_bool($this->contents)) {
56 $this->error('must be a boolean');
57 }
58 return $this;
59 }

References error().

+ 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.

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 }

References assertIsArray(), and error().

+ 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.

43 {
44 if (!is_string($this->contents)) {
45 $this->error('must be a string');
46 }
47 return $this;
48 }

References error().

Referenced by assertAlnum().

+ 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.

99 {
100 if (empty($this->contents)) {
101 $this->error('must not be empty');
102 }
103 return $this;
104 }

References error().

+ 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.

76 {
77 if ($this->contents === null) {
78 $this->error('must not be null');
79 }
80 return $this;
81 }

References error().

+ 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.

125 {
126 throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member) . ' in ' . $this->context . ' ' . $msg);
127 }
Exceptions related to configuration schema.
Definition: Exception.php:7

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

+ Here is the caller graph for this function:

Field Documentation

◆ $contents

HTMLPurifier_ConfigSchema_ValidatorAtom::$contents
protected

@type mixed

Definition at line 29 of file ValidatorAtom.php.

◆ $context

HTMLPurifier_ConfigSchema_ValidatorAtom::$context
protected

@type string

Definition at line 14 of file ValidatorAtom.php.

Referenced by __construct().

◆ $member

HTMLPurifier_ConfigSchema_ValidatorAtom::$member
protected

@type string

Definition at line 24 of file ValidatorAtom.php.

Referenced by __construct().

◆ $obj

HTMLPurifier_ConfigSchema_ValidatorAtom::$obj
protected

@type object

Definition at line 19 of file ValidatorAtom.php.

Referenced by __construct().


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