1. Go to this page and download the library: Download nicoswd/php-rule-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nicoswd / php-rule-parser example snippets
$variables = ['foo' => 6];
$rule = new Rule('foo in [4, 6, 7]', $variables);
var_dump($rule->isTrue()); // bool(true)
class User
{
// ...
public function points(): int
{
return 1337;
}
}
$variables = [
'user' => new User(),
];
$rule = new Rule('user.points() > 300', $variables);
var_dump($rule->isTrue()); // bool(true)