Conditions | 9 |
Paths | 9 |
Total Lines | 33 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function filter(array $items): array |
||
20 | { |
||
21 | $res = []; |
||
22 | |||
23 | foreach($items as $item) |
||
24 | { |
||
25 | if(!array_key_exists('auth', $item) || $item['auth']() === true) |
||
26 | { |
||
27 | if(array_key_exists('items', $item)) |
||
28 | { |
||
29 | $newItems = []; |
||
30 | foreach($item['items'] as $subItem) |
||
31 | { |
||
32 | if(!array_key_exists('auth', $subItem) || $subItem['auth']() === true) |
||
33 | { |
||
34 | $newItems[] = $this->itemProcessor->process($subItem); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | if(count($newItems) > 0) |
||
39 | { |
||
40 | $item['items'] = $newItems; |
||
41 | $res[] = $this->itemProcessor->process($item); |
||
42 | } |
||
43 | } |
||
44 | else |
||
45 | { |
||
46 | $res[] = $this->itemProcessor->process($item); |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 | |||
51 | return $res; |
||
52 | } |
||
53 | } |