Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
85.71% |
6 / 7 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
OrderBySearchFilter | |
85.71% |
6 / 7 |
|
75.00% |
3 / 4 |
5.07 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFilterName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getWhereCondition | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getOrderByCode | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
2.15 |
1 | <?php |
2 | |
3 | namespace Apie\DoctrineEntityDatalayer\Query; |
4 | |
5 | use Apie\Core\Datalayers\Search\QuerySearch; |
6 | use Apie\DoctrineEntityDatalayer\Enums\SortingOrder; |
7 | use Doctrine\DBAL\Connection; |
8 | |
9 | class OrderBySearchFilter implements OrderByFilterInterface |
10 | { |
11 | private ?string $search = null; |
12 | public function __construct( |
13 | private readonly string $filterName, |
14 | private readonly string $propertyName |
15 | ) { |
16 | } |
17 | |
18 | public function getFilterName(): string |
19 | { |
20 | return $this->filterName; |
21 | } |
22 | |
23 | public function getWhereCondition(QuerySearch $querySearch, Connection $connection): string |
24 | { |
25 | $this->search = $querySearch->getOrderBy()[$this->filterName] ?? null; |
26 | return '1'; |
27 | } |
28 | |
29 | public function getOrderByCode(SortingOrder $sortingOrder): string |
30 | { |
31 | if ($this->search === null) { |
32 | return ''; |
33 | } |
34 | return 'entity.' . $this->propertyName . ' ' . $sortingOrder->value; |
35 | } |
36 | } |