Boolean Evaluator
, (*1)
This is an experiment in PHP to build up an expression that can be evaluated in
arbitrary ways. It wasn't meant for production, but if you're interested drop
me a line and I'll start tagging releases., (*2)
Install
Via Composer, (*3)
``` bash
$ composer require davidrjonas/boolean-evaluator, (*4)
Usage
-----
```php
<?php
require __DIR__ . '/vendor/autoload.php';
use DavidRJonas\BooleanEvaluator as B;
$expr = (new B\Expression)
->bAnd('A', 'B')
->bOr('C', 'D')
->bNot(
(new B\Expression)->bAnd('C', 'D')
);
print (new B\Evaluator\Stringer)->apply($expr);
// output: A and B and (C or D) and not (C and D)
$evaluator = new B\Evaluator\SetContains;
var_dump($evaluator->apply($expr, ['A', 'B', 'C'])); // true
var_dump($evaluator->apply($expr, ['A', 'B', 'D'])); // true
var_dump($evaluator->apply($expr, ['A', 'B'])); // false, a C or D is missing
var_dump($evaluator->apply($expr, ['A', 'B', 'C', 'D'])); // false, C or D but not both
License
The MIT License (MIT). Please see License File for more information., (*5)