ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 

Data Fields

 $obj
 
 $member
 
 $contents
 

Protected Member Functions

 error ($msg)
 

Protected Attributes

 $context
 

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 14 of file ValidatorAtom.php.

References $context, $member, and $obj.

14  {
15  $this->context = $context;
16  $this->obj = $obj;
17  $this->member = $member;
18  $this->contents =& $obj->$member;
19  }

Member Function Documentation

◆ assertAlnum()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertAlnum ( )

Definition at line 41 of file ValidatorAtom.php.

References assertIsString(), and error().

41  {
42  $this->assertIsString();
43  if (!ctype_alnum($this->contents)) $this->error('must be alphanumeric');
44  return $this;
45  }
+ Here is the call graph for this function:

◆ assertIsArray()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertIsArray ( )

Definition at line 31 of file ValidatorAtom.php.

References error().

Referenced by assertIsLookup().

31  {
32  if (!is_array($this->contents)) $this->error('must be an array');
33  return $this;
34  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assertIsBool()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertIsBool ( )

Definition at line 26 of file ValidatorAtom.php.

References error().

26  {
27  if (!is_bool($this->contents)) $this->error('must be a boolean');
28  return $this;
29  }
+ Here is the call graph for this function:

◆ assertIsLookup()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertIsLookup ( )

Definition at line 52 of file ValidatorAtom.php.

References assertIsArray(), and error().

52  {
53  $this->assertIsArray();
54  foreach ($this->contents as $v) {
55  if ($v !== true) $this->error('must be a lookup array');
56  }
57  return $this;
58  }
+ Here is the call graph for this function:

◆ assertIsString()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertIsString ( )

Definition at line 21 of file ValidatorAtom.php.

References error().

Referenced by assertAlnum().

21  {
22  if (!is_string($this->contents)) $this->error('must be a string');
23  return $this;
24  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assertNotEmpty()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertNotEmpty ( )

Definition at line 47 of file ValidatorAtom.php.

References error().

47  {
48  if (empty($this->contents)) $this->error('must not be empty');
49  return $this;
50  }
+ Here is the call graph for this function:

◆ assertNotNull()

HTMLPurifier_ConfigSchema_ValidatorAtom::assertNotNull ( )

Definition at line 36 of file ValidatorAtom.php.

References error().

36  {
37  if ($this->contents === null) $this->error('must not be null');
38  return $this;
39  }
+ Here is the call graph for this function:

◆ error()

HTMLPurifier_ConfigSchema_ValidatorAtom::error (   $msg)
protected

Definition at line 60 of file ValidatorAtom.php.

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

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

Field Documentation

◆ $contents

HTMLPurifier_ConfigSchema_ValidatorAtom::$contents

Definition at line 12 of file ValidatorAtom.php.

◆ $context

HTMLPurifier_ConfigSchema_ValidatorAtom::$context
protected

Definition at line 12 of file ValidatorAtom.php.

Referenced by __construct().

◆ $member

HTMLPurifier_ConfigSchema_ValidatorAtom::$member

Definition at line 12 of file ValidatorAtom.php.

Referenced by __construct().

◆ $obj

HTMLPurifier_ConfigSchema_ValidatorAtom::$obj

Definition at line 12 of file ValidatorAtom.php.

Referenced by __construct().


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