bobthecow / Ruler

A simple stateless production rules engine for modern PHP
MIT License
1.06k stars 140 forks source link

New tag #32

Closed bakura10 closed 10 years ago

bakura10 commented 10 years ago

Hi,

Would it be possible to tag a new version? Latest version does not include the trait :).

Thanks!

bobthecow commented 10 years ago

Yep. Totally possible :)

bakura10 commented 10 years ago

Nice :)

bobthecow commented 10 years ago

Before we tag a new release, we need to get the documentation updated for all the new operators. I'll do that when I get a minute.

bakura10 commented 10 years ago

Speaking about that, I've thought of a missing operator that would be useful: Exists operator. It would be used to make sure that a given key exist in the context:

$rb = new RuleBuilder;
$rule = $rb->create(
    $rb->logicalAnd(
        $rb['foo']->exists(),
        $rb['bar']->exists()
    )
);

$context = new Context(array(
    'foo' => 5,
    'bar' => null
));

$rule->execute($context); // return true

$context = new Context(array(
    'foo' => 5
));

$rule->execute($context); // return false

However I'm not sure how this would make to current architecture as exists() operator would not take a right operand.

bobthecow commented 10 years ago

Done! Sorry that took so long :(