bobthecow / Ruler

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

Improvements #22

Closed VEnis closed 10 years ago

VEnis commented 10 years ago

I have used Ruler library in one of my projects and it is sometimes very helpful to be possible to get conditions from the rule and logical operators back after their instances are created. So I have added required methods. All existing tests are passed.

bobthecow commented 10 years ago

Hi @VEnis. Sorry about the delay. I just had a kid and pull requests got a bit behind :)

This has actually been implemented in the develop branch for a while.

https://github.com/bobthecow/Ruler/blob/develop/src/Ruler/Operator.php

You'd use it like:

list($left, $right) = $op->getOperands();

How many you get back depends, of course, on the arity of the operator (unary, binary, or n-operand).

Check out the develop branch and let me know if it does everything you're looking for?