Download the PHP package cleverage/ruler without Composer
On this page you can find all versions of the php package cleverage/ruler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cleverage/ruler
More information about cleverage/ruler
Files in cleverage/ruler
Package ruler
Short Description A business rules engine
License MIT
Homepage https://github.com/cleverage/Ruler
Informations about the package ruler
Ruler
cleverage/Ruler is a PHP 5.3 Library. Use it to implement your own business rules, and link them in order to check if you are satisfying the set.
Exemple :
You want to check if the current user can activate a feature. For this, you have to check that :
- he is connected,
- he has the premium suscription,
- he has enough money in his account.
Combination of rules can even be done in a single rule class, in order to simplify your application code and increase maintability.
Now, you can use this rule class everywhere you need it, and just change the construct to have th rules reverberated everewhere.
How logic is handled
The order in which you set OR/AND/NAND rules is not important. At the end, they are grouped by type.
1) You want your ruleset satisfied :
2) You want your ruleset not satisfied :
by default, isNotSatisfied() returns !isSatisfied(). But sometimes, you may want to personnalize the doIsNotSatisfied() method in order to optimize workflow (like SQL queries).
Customization
Setting Exception class and message error
If you have one generic rule (e.g. : ObjectIsEqual), you may need to have different exception thrown when composing complex rules. Each Rule has a setter for this :