Total Complexity | 9 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | trait WithFilters |
||
11 | { |
||
12 | /** |
||
13 | * @param array<(string|\Zing\QueryBuilder\Filter)>|string|\Zing\QueryBuilder\Filter $filters |
||
14 | * |
||
15 | * @return $this |
||
16 | */ |
||
17 | 43 | public function enableFilters($filters) |
|
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param array<(string|\Zing\QueryBuilder\Filter)> $filters |
||
27 | */ |
||
28 | 47 | protected function formatFilters(array $filters): Collection |
|
29 | { |
||
30 | 47 | return collect($filters)->map( |
|
31 | 47 | function ($filter): Filter { |
|
32 | 47 | if ($filter instanceof Filter) { |
|
33 | 45 | return $filter; |
|
34 | } |
||
35 | |||
36 | 2 | return Filter::exact($filter); |
|
37 | } |
||
38 | ); |
||
39 | } |
||
40 | |||
41 | 43 | protected function applyFilters(Collection $filters): void |
|
54 | } |
||
55 | } |
||
56 | ); |
||
57 | } |
||
58 | |||
59 | 45 | protected function isRequestedFilter(Filter $filter): bool |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return mixed |
||
66 | */ |
||
67 | 42 | protected function getFilterValue(Filter $filter) |
|
72 |