Total Complexity | 8 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | abstract class AbstractFilter extends AbstractDto implements FilterInterface |
||
14 | { |
||
15 | /** |
||
16 | * @param array $data |
||
17 | */ |
||
18 | public function populate(array $data): void |
||
19 | { |
||
20 | foreach ($data as $key => $value) { |
||
21 | if (isset($value->type) && isset($value->value)) { |
||
22 | $filterItem = new BaseFilterItem(); |
||
23 | $filterItem->setType($value->type); |
||
24 | $filterItem->setValue($value->value); |
||
25 | $this->$key = $filterItem; |
||
26 | } |
||
27 | } |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @return array |
||
32 | */ |
||
33 | public function toArray(): array |
||
34 | { |
||
35 | $data = parent::toArray(); |
||
36 | |||
37 | return $this->filterDataToArray($data); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param array $data |
||
42 | * @return array |
||
43 | */ |
||
44 | public function filterDataToArray(array $data): array |
||
56 | } |
||
57 | } |
||
58 |