Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
15 / 15 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
In | |
100.00% |
15 / 15 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
create | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
2 | |||
filter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Projom\Storage\SQL\Component\Filter; |
6 | |
7 | use Projom\Storage\SQL\Component\Column; |
8 | use Projom\Storage\SQL\Component\Filter\Util; |
9 | use Projom\Storage\SQL\Util\Operator; |
10 | |
11 | class In |
12 | { |
13 | public static function create(Column $column, Operator $operator, array $values, int $filterID): array |
14 | { |
15 | $parameterName = Util::parameterName($column->fields(), $filterID); |
16 | |
17 | $parameters = []; |
18 | $params = []; |
19 | foreach ($values as $id => $value) { |
20 | $id++; |
21 | $parameter = "{$parameterName}_{$id}"; |
22 | $parameters[] = ":$parameter"; |
23 | $params[$parameter] = $value; |
24 | } |
25 | |
26 | $parameterString = Util::join($parameters, ', '); |
27 | |
28 | $filter = static::filter($column, $operator, $parameterString); |
29 | |
30 | return [ |
31 | $filter, |
32 | $params |
33 | ]; |
34 | } |
35 | |
36 | public static function filter(Column $column, Operator $operator, string $parameterString): string |
37 | { |
38 | return "$column {$operator->value} ( $parameterString )"; |
39 | } |
40 | } |