Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| SpecificationAbstract | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| addSuffixToParams | |
100.00% |
11 / 11 |
|
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 | abstract readonly class SpecificationAbstract implements SpecificationInterface |
| 13 | { |
| 14 | protected function addSuffixToParams(array $sqlResult, string $suffix): array |
| 15 | { |
| 16 | $sql = $sqlResult['sql']; |
| 17 | $params = $sqlResult['params']; |
| 18 | $newParams = []; |
| 19 | |
| 20 | foreach ($params as $key => $value) { |
| 21 | $newKey = $key.'_'.$suffix; |
| 22 | $newParams[$newKey] = $value; |
| 23 | $sql = str_replace(':'.$key, ':'.$newKey, $sql); |
| 24 | } |
| 25 | |
| 26 | return [ |
| 27 | 'sql' => $sql, |
| 28 | 'params' => $newParams, |
| 29 | ]; |
| 30 | } |
| 31 | } |