| Total Complexity | 9 | 
| Total Lines | 43 | 
| Duplicated Lines | 0 % | 
| Coverage | 42.86% | 
| Changes | 2 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 12 | class BoolExpression | ||
| 13 | { | ||
| 14 | |||
| 15 | /** @var AbstractOperator[] */ | ||
| 16 | private $operators = []; | ||
| 17 | |||
| 18 | public function __construct(callable $checker) | ||
| 19 |     { | ||
| 20 | $this->operators[] = new AndOperator($checker); | ||
| 21 | } | ||
| 22 | |||
| 23 | public static function with(callable $checker): self | ||
| 24 |     { | ||
| 25 | return new self($checker); | ||
| 26 | } | ||
| 27 | |||
| 28 | 1 | public function __invoke($item): bool | |
| 29 |     { | ||
| 30 | 1 | $operand = null; | |
| 31 | 1 |         foreach ($this->operators as $operator) { | |
| 32 | 1 |             if ($operand === null) { | |
| 33 | 1 |                 if (!$operand = $operator->getChecker()($item)) { | |
| 34 | return false; | ||
| 35 | } | ||
| 36 | 1 | continue; | |
| 37 | } | ||
| 38 | 1 |             if (!$operand = $operator($operand, $item)) { | |
| 39 | 1 | return false; | |
| 40 | } | ||
| 41 | } | ||
| 42 | 1 | return true; | |
| 43 | } | ||
| 44 | |||
| 45 | public function and(callable $checker): self | ||
| 46 |     { | ||
| 47 | $this->operators[] = new AndOperator($checker); | ||
| 48 | return $this; | ||
| 49 | } | ||
| 50 | |||
| 51 | public function or(callable $checker): self | ||
| 55 | } | ||
| 56 | |||
| 57 | } | ||
| 58 |