Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| UserIdSpecification | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toSql | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| toInMemoryFilter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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 AppDemo\Loan\Domain\Specification; |
| 11 | |
| 12 | use Phexium\Domain\Id\IdInterface; |
| 13 | use Phexium\Domain\Specification\SpecificationInterface; |
| 14 | |
| 15 | final readonly class UserIdSpecification implements SpecificationInterface |
| 16 | { |
| 17 | public function __construct( |
| 18 | private IdInterface $userId |
| 19 | ) {} |
| 20 | |
| 21 | public function toSql(): array |
| 22 | { |
| 23 | return [ |
| 24 | 'sql' => 'user_id = :user_id', |
| 25 | 'params' => ['user_id' => $this->userId->getValue()], |
| 26 | ]; |
| 27 | } |
| 28 | |
| 29 | public function toInMemoryFilter(): callable |
| 30 | { |
| 31 | return fn (array $row): bool => $row['user_id'] === $this->userId->getValue(); |
| 32 | } |
| 33 | } |