Hoa central
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Hoa\Ruler\Ruler Class Reference

Public Member Functions

 assert ($rule, Context $context=null)
 
 setAsserter (HVisitor\Visit $visitor)
 
 getAsserter (Context $context=null)
 

Static Public Member Functions

static interpret ($rule)
 
static interprete ($rule)
 
static getInterpreter ()
 
static getDefaultAsserter (Context $context=null)
 
static getCompiler ()
 

Protected Attributes

 $_asserter = null
 

Static Protected Attributes

static $_compiler = null
 
static $_interpreter = null
 
static $_defaultAsserter = null
 

Detailed Description

Class .

Ruler helpers.

Definition at line 52 of file Ruler.php.

Member Function Documentation

Hoa\Ruler\Ruler::assert (   $rule,
Context  $context = null 
)

Assert.

Parameters
mixed$ruleRule (string or model)
\Hoa\Ruler\Context$contextContext.
Returns
bool
Exceptions

Definition at line 92 of file Ruler.php.

93  {
94  if (is_string($rule)) {
95  $rule = static::interprete($rule);
96  }
97 
98  if (null === $context) {
99  $context = new Context();
100  }
101 
102  return $this->getAsserter($context)->visit($rule);
103  }
getAsserter(Context $context=null)
Definition: Ruler.php:166

Here is the call graph for this function:

Hoa\Ruler\Ruler::getAsserter ( Context  $context = null)

Get asserter.

Parameters
\Hoa\Ruler\Context$contextContext.
Returns

Definition at line 166 of file Ruler.php.

167  {
168  if (null === $asserter = $this->_asserter) {
169  return static::getDefaultAsserter($context);
170  }
171 
172  if (null !== $context) {
173  $asserter->setContext($context);
174  }
175 
176  return $asserter;
177  }

Here is the caller graph for this function:

static Hoa\Ruler\Ruler::getCompiler ( )
static

Get compiler.

Returns

Definition at line 203 of file Ruler.php.

204  {
205  if (null === static::$_compiler) {
206  static::$_compiler = Compiler\Llk::load(
207  new File\Read('hoa://Library/Ruler/Grammar.pp')
208  );
209  }
210 
211  return static::$_compiler;
212  }
static Hoa\Ruler\Ruler::getDefaultAsserter ( Context  $context = null)
static

Get default asserter.

Parameters
\Hoa\Ruler\Context$contextContext.
Returns

Definition at line 185 of file Ruler.php.

186  {
187  if (null === static::$_defaultAsserter) {
188  static::$_defaultAsserter = new Visitor\Asserter($context);
189  }
190 
191  if (null !== $context) {
192  static::$_defaultAsserter->setContext($context);
193  }
194 
195  return static::$_defaultAsserter;
196  }
static Hoa\Ruler\Ruler::getInterpreter ( )
static

Get interpreter.

Returns

Definition at line 137 of file Ruler.php.

138  {
139  if (null === static::$_interpreter) {
140  static::$_interpreter = new Visitor\Interpreter();
141  }
142 
143  return static::$_interpreter;
144  }
static Hoa\Ruler\Ruler::interpret (   $rule)
static

Alias to the self::interprete method.

Parameters
string$ruleRule.
Returns
Exceptions

Definition at line 112 of file Ruler.php.

113  {
114  return static::getInterpreter()->visit(
115  static::getCompiler()->parse($rule)
116  );
117  }
static Hoa\Ruler\Ruler::interprete (   $rule)
static

Short interpreter.

Parameters
string$ruleRule.
Returns
Exceptions

Definition at line 127 of file Ruler.php.

128  {
129  return static::interpret($rule);
130  }
Hoa\Ruler\Ruler::setAsserter ( HVisitor\Visit  $visitor)

Set current asserter.

Parameters
\Hoa\Visitor\Visit$visitorVisitor.
Returns

Definition at line 152 of file Ruler.php.

153  {
154  $old = $this->_asserter;
155  $this->_asserter = $visitor;
156 
157  return $old;
158  }

Member Data Documentation

Hoa\Ruler\Ruler::$_asserter = null
protected

Definition at line 73 of file Ruler.php.

Hoa\Ruler\Ruler::$_compiler = null
staticprotected

Definition at line 59 of file Ruler.php.

Hoa\Ruler\Ruler::$_defaultAsserter = null
staticprotected

Definition at line 80 of file Ruler.php.

Hoa\Ruler\Ruler::$_interpreter = null
staticprotected

Definition at line 66 of file Ruler.php.


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