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

Public Member Functions

 __construct ($name, Array $arguments=[], $isFunction=true)
 
 getName ()
 
 getArguments ()
 
 isFunction ()
 
 isLazy ()
 
 shouldBreakLazyEvaluation ($value)
 
 accept (Visitor\Visit $visitor, &$handle=null, $eldnah=null)
 
- Public Member Functions inherited from Hoa\Visitor\Element
 accept (Visit $visitor, &$handle=null, $eldnah=null)
 

Static Public Member Functions

static isToken ($operator)
 

Public Attributes

const LAZY_BREAK = false
 
const LAZY_CONTINUE = true
 

Protected Member Functions

 setName ($name)
 
 setArguments (Array $arguments)
 
 setFunction ($isFunction)
 
 setLaziness ($isLazy)
 

Protected Attributes

 $_name = null
 
 $_arguments = null
 
 $_function = true
 
 $_laziness = false
 

Detailed Description

Class .

Represent an operator or a function (in prefixed notation).

Definition at line 49 of file Operator.php.

Constructor & Destructor Documentation

Hoa\Ruler\Model\Operator::__construct (   $name,
Array  $arguments = [],
  $isFunction = true 
)

Constructor.

Parameters
string$nameName.
array$argumentsArguments.
bool$isFunctionWhether it is a function.
Returns
void

Definition at line 101 of file Operator.php.

105  {
106  $this->setName($name);
107  $this->setLaziness('and' === $name || 'or' === $name);
108  $this->setArguments($arguments);
109  $this->setFunction($isFunction);
110 
111  return;
112  }
setFunction($isFunction)
Definition: Operator.php:176
setArguments(Array $arguments)
Definition: Operator.php:144

Here is the call graph for this function:

Member Function Documentation

Hoa\Ruler\Model\Operator::accept ( Visitor\Visit  $visitor,
$handle = null,
  $eldnah = null 
)

Accept a visitor.

Parameters
\Hoa\Visitor\Visit$visitorVisitor.
mixed&$handleHandle (reference).
mixed$eldnahHandle (no reference).
Returns
mixed

Definition at line 266 of file Operator.php.

270  {
271  return $visitor->visit($this, $handle, $eldnah);
272  }
Hoa\Ruler\Model\Operator::getArguments ( )

Get arguments.

Returns
array

Definition at line 165 of file Operator.php.

166  {
167  return $this->_arguments;
168  }
Hoa\Ruler\Model\Operator::getName ( )

Get name.

Returns
string

Definition at line 133 of file Operator.php.

134  {
135  return $this->_name;
136  }
Hoa\Ruler\Model\Operator::isFunction ( )

Check if the operator is a function or not.

Returns
bool

Definition at line 189 of file Operator.php.

190  {
191  return $this->_function;
192  }
Hoa\Ruler\Model\Operator::isLazy ( )

Check if the operator is lazy or not.

Returns
bool

Definition at line 213 of file Operator.php.

214  {
215  return $this->_laziness;
216  }
static Hoa\Ruler\Model\Operator::isToken (   $operator)
static

Check if the operator is a token of the grammar or not.

Parameters
string$operatorOperator.
Returns
bool

Definition at line 251 of file Operator.php.

252  {
253  static $_tokens = ['not', 'and', 'or', 'xor'];
254 
255  return true === in_array($operator, $_tokens);
256  }
Hoa\Ruler\Model\Operator::setArguments ( Array  $arguments)
protected

Set arguments.

Parameters
array$argumentsArguments.
Returns
array

Definition at line 144 of file Operator.php.

145  {
146  foreach ($arguments as &$argument) {
147  if (is_scalar($argument) || null === $argument) {
148  $argument = new Bag\Scalar($argument);
149  } elseif (is_array($argument)) {
150  $argument = new Bag\RulerArray($argument);
151  }
152  }
153 
154  $old = $this->_arguments;
155  $this->_arguments = $arguments;
156 
157  return $old;
158  }

Here is the caller graph for this function:

Hoa\Ruler\Model\Operator::setFunction (   $isFunction)
protected

Set whether the operator is a function or not.

Parameters
bool$isFunctionIs a function or not.
Returns
bool

Definition at line 176 of file Operator.php.

177  {
178  $old = $this->_function;
179  $this->_function = $isFunction;
180 
181  return $old;
182  }

Here is the caller graph for this function:

Hoa\Ruler\Model\Operator::setLaziness (   $isLazy)
protected

Set whether the operator is lazy or not.

Parameters
bool$isLazyIs a lazy operator or not.
Returns
bool

Definition at line 200 of file Operator.php.

201  {
202  $old = $this->_laziness;
203  $this->_laziness = $isLazy;
204 
205  return $old;
206  }

Here is the caller graph for this function:

Hoa\Ruler\Model\Operator::setName (   $name)
protected

Set name.

Parameters
string$nameName.
Returns
string

Definition at line 120 of file Operator.php.

121  {
122  $old = $this->_name;
123  $this->_name = $name;
124 
125  return $old;
126  }

Here is the caller graph for this function:

Hoa\Ruler\Model\Operator::shouldBreakLazyEvaluation (   $value)

Check whether we should break the lazy evaluation or not.

Parameters
mixed$valueValue to check.
Returns
bool

Definition at line 224 of file Operator.php.

225  {
226  switch ($this->_name) {
227  case 'and':
228  if (false === $value) {
229  return self::LAZY_BREAK;
230  }
231 
232  break;
233 
234  case 'or':
235  if (true === $value) {
236  return self::LAZY_BREAK;
237  }
238 
239  break;
240  }
241 
242  return self::LAZY_CONTINUE;
243  }

Member Data Documentation

Hoa\Ruler\Model\Operator::$_arguments = null
protected

Definition at line 77 of file Operator.php.

Hoa\Ruler\Model\Operator::$_function = true
protected

Definition at line 84 of file Operator.php.

Hoa\Ruler\Model\Operator::$_laziness = false
protected

Definition at line 91 of file Operator.php.

Hoa\Ruler\Model\Operator::$_name = null
protected

Definition at line 70 of file Operator.php.

const Hoa\Ruler\Model\Operator::LAZY_BREAK = false

Lazy evaluation should break.

bool

Definition at line 56 of file Operator.php.

const Hoa\Ruler\Model\Operator::LAZY_CONTINUE = true

Lazy evaluation should continue.

bool

Definition at line 63 of file Operator.php.


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