Conditions | 9 |
Paths | 10 |
Total Lines | 29 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 9.7971 |
Changes | 0 |
1 | <?php |
||
33 | 12 | public function isGranted(Feature $feature) |
|
34 | { |
||
35 | // feature is enabled without required roles |
||
36 | // there's no need to check on user roles |
||
37 | 12 | if (empty($feature->getRole()) && empty($feature->getParentRole())) { |
|
38 | 8 | return $feature->isEnabled(); |
|
39 | } |
||
40 | |||
41 | 4 | if (null === $this->context) { |
|
42 | return false; |
||
43 | } |
||
44 | |||
45 | 4 | if (!$feature->isEnabled()) { |
|
46 | return false; |
||
47 | } |
||
48 | |||
49 | 4 | if ($feature->getRole()) { |
|
50 | 4 | if (!$this->context->isGranted($feature->getRole())) { |
|
51 | return false; |
||
52 | } |
||
53 | } |
||
54 | |||
55 | 4 | if ('' !== trim($feature->getParentRole())) { |
|
56 | 2 | if (!$this->context->isGranted($feature->getParentRole())) { |
|
57 | 2 | return false; |
|
58 | } |
||
59 | } |
||
60 | |||
61 | 2 | return true; |
|
62 | } |
||
64 |