Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Ruler\Context Class Reference
Inheritance diagram for Hoa\Ruler\Context:

Public Member Functions

 __construct (Array $data=[])
 
 offsetSet ($id, $value)
 
 offsetGet ($id)
 
 offsetExists ($id)
 
 offsetUnset ($id)
 

Protected Attributes

 $_ruler = null
 
 $_data = []
 

Detailed Description

Class .

Context of a rule, it contains data to instanciate the rule.

Definition at line 47 of file Context.php.

Constructor & Destructor Documentation

Hoa\Ruler\Context::__construct ( Array  $data = [])

Constructor.

Parameters
array$dataInitial data.
Returns
void

Definition at line 71 of file Context.php.

72  {
73  $this->_data = $data;
74 
75  return;
76  }

Member Function Documentation

Hoa\Ruler\Context::offsetExists (   $id)

Check if a data exists.

Returns
bool

Definition at line 132 of file Context.php.

133  {
134  return true === array_key_exists($id, $this->_data);
135  }
Hoa\Ruler\Context::offsetGet (   $id)

Get a data.

Parameters
string$idID.
Returns
mixed
Exceptions

Definition at line 99 of file Context.php.

100  {
101  if (false === array_key_exists($id, $this->_data)) {
102  throw new Exception(
103  'Identifier %s does not exist in the context.',
104  0,
105  $id
106  );
107  }
108 
109  $value = $this->_data[$id];
110 
111  if ($value instanceof DynamicCallable) {
112  return $value($this);
113  }
114 
115  if (true === is_callable($value)) {
116  if (true === is_string($value) &&
117  false === in_array(strtolower($value), get_defined_functions()['user'])) {
118  return $value;
119  }
120 
121  $value = $this->_data[$id] = $value($this);
122  }
123 
124  return $value;
125  }
Hoa\Ruler\Context::offsetSet (   $id,
  $value 
)

Set a data.

Parameters
string$idID.
mixed$valueValue.
Returns
void

Definition at line 85 of file Context.php.

86  {
87  $this->_data[$id] = $value;
88 
89  return;
90  }
Hoa\Ruler\Context::offsetUnset (   $id)

Unset a data.

Parameters
string$idID.
Returns
void

Definition at line 143 of file Context.php.

144  {
145  unset($this->_data[$id]);
146 
147  return;
148  }

Member Data Documentation

Hoa\Ruler\Context::$_data = []
protected

Definition at line 61 of file Context.php.

Hoa\Ruler\Context::$_ruler = null
protected

Definition at line 54 of file Context.php.


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