villaflor / decree
Rule Engine
Fund package maintenance!
villaflor
Requires
- php: ^8.0|^8.1
Requires (Dev)
- laravel/pint: ^1.3
- pestphp/pest: ^1.22
This package is auto-updated.
Last update: 2024-10-09 04:52:52 UTC
README
Chain Command.
Installation
You can install the package via composer:
composer require villaflor/decree
Usage
$data = [ 'roi' => 1 ]; // action list $noAction = new NoAction(); $terminalLog = new TerminalLog(); //rule list $isRoiGreaterThan1 = new GreaterThan($data['roi'], 1); $isRoiLessThan1 = new LessThan($data['roi'], 1); $isRoiEquals1 = new Equals($data['roi'], 1); $isRoiEquals1Strict = new Equals($data['roi'], 1, true); $secondNode = new Node([ [ 'rule' => $isRoiEquals1, 'next' => $noAction, ], [ 'rule' => $isRoiEquals1, 'next' => $terminalLog, ], ]); $firstNode = new Node([ [ 'rule' =>$isRoiEquals1Strict, 'next' => $secondNode, ], [ 'rule' => $isRoiGreaterThan1, 'next' => $terminalLog, ], [ 'rule' => $isRoiLessThan1, 'next' => $terminalLog, ] ]); $x = $firstNode->handle($data); var_dump($x);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.