Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
BinaryXorSpecification
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 getSqlTemplate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 evaluateBinary
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10namespace Phexium\Domain\Specification;
11
12use Override;
13
14// Use case: Book is either available OR reserved, but not both states
15// $spec = new BinaryXorSpecification($isAvailable, $isReserved);
16final readonly class BinaryXorSpecification extends BinaryAbstract
17{
18    #[Override]
19    protected function getSqlTemplate(): string
20    {
21        return '((LEFT) AND NOT (RIGHT)) OR (NOT (LEFT) AND (RIGHT))';
22    }
23
24    #[Override]
25    protected function evaluateBinary(
26        callable $leftFilter,
27        callable $rightFilter,
28        array $row
29    ): bool {
30        return ($leftFilter($row) && !$rightFilter($row)) || (!$leftFilter($row) && $rightFilter($row));
31    }
32}