Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| BinaryAndSpecification | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| getSqlTemplate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| evaluateBinary | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace Phexium\Domain\Specification; |
| 11 | |
| 12 | use Override; |
| 13 | |
| 14 | // Use case: Find books by specific author AND published after 2020 |
| 15 | // $spec = new BinaryAndSpecification($authorSpec, $yearSpec); |
| 16 | final readonly class BinaryAndSpecification extends BinaryAbstract |
| 17 | { |
| 18 | #[Override] |
| 19 | protected function getSqlTemplate(): string |
| 20 | { |
| 21 | return '(LEFT) AND (RIGHT)'; |
| 22 | } |
| 23 | |
| 24 | #[Override] |
| 25 | protected function evaluateBinary(callable $leftFilter, callable $rightFilter, array $row): bool |
| 26 | { |
| 27 | return $leftFilter($row) && $rightFilter($row); |
| 28 | } |
| 29 | } |