Skip to content

Instantly share code, notes, and snippets.

@stephpy
Created July 5, 2013 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephpy/5935317 to your computer and use it in GitHub Desktop.
Save stephpy/5935317 to your computer and use it in GitHub Desktop.
<?php
$rule = "foo(foo,'bar') = in_array(1, ('1', '2'))";
$ruler = new Hoa\Ruler\Ruler();
$ruler->addFunction('foo', function(array $args) {
return $args[0] == $args[1];
});
$ruler->addFunction('in_array', function(array $args) {
return 1;
return in_array($args[0], $args[1]);
});
$object = $ruler->interprete($rule);
$context = new Hoa\Ruler\Asserter\Context();
$context['foo'] = 'bar';
print "<pre>";
var_dump($ruler->assert($rule, $context));
print "</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment