Total Complexity | 5 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | class FilterByRole implements NavigationFilterInterface |
||
16 | { |
||
17 | /** @var string[] */ |
||
18 | private $roles; |
||
19 | |||
20 | public function __construct(RolesProviderInterface $roleProvider) |
||
23 | } |
||
24 | |||
25 | public function filterItems(MutableContainerInterface $container): MutableContainerInterface |
||
26 | { |
||
27 | $filtered = clone $container; |
||
28 | $filtered->reset(); |
||
29 | |||
30 | array_map( |
||
31 | [$filtered, 'add'], |
||
32 | array_filter( |
||
33 | $container->getItems(), |
||
34 | [$this, 'filter'] |
||
35 | ) |
||
36 | ); |
||
37 | |||
38 | return $filtered; |
||
39 | } |
||
40 | |||
41 | private function filter(HasSupportedRolesInterface $item): bool |
||
50 | } |
||
51 | } |
||
52 |