Total Complexity | 8 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
11 | class Visitor extends NodeVisitorAbstract |
||
12 | { |
||
13 | /** @var string[] */ |
||
14 | private array $roles = []; |
||
15 | |||
16 | /** @var string[] */ |
||
17 | private array $permissions = []; |
||
18 | |||
19 | /** @inerhitDoc */ |
||
20 | public function enterNode(Node $node) |
||
21 | { |
||
22 | if (!$node instanceof ArrayItem) { |
||
23 | return; |
||
24 | } |
||
25 | |||
26 | if ($node->key instanceof String_) { |
||
27 | $this->roles[] = $node->key->value; |
||
28 | } |
||
29 | |||
30 | if ( |
||
31 | $node->value instanceof String_ |
||
32 | && !in_array($node->value->value, $this->permissions) |
||
33 | && !strstr($node->value->value, 'role:') |
||
34 | ) { |
||
35 | $this->permissions[] = $node->value->value; |
||
36 | } |
||
37 | } |
||
38 | |||
39 | public function getRoles(): array |
||
42 | } |
||
43 | |||
44 | public function getPermissions(): array |
||
47 | } |
||
48 | } |
||
49 |