| Conditions | 8 |
| Paths | 10 |
| Total Lines | 29 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 8.1867 |
| 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 (!$feature->requiresRoleCheck()) { |
|
| 38 | 4 | return $feature->isEnabled(); |
|
| 39 | } |
||
| 40 | |||
| 41 | 8 | if (null === $this->context) { |
|
| 42 | return false; |
||
| 43 | } |
||
| 44 | |||
| 45 | 8 | if (!$feature->isEnabled()) { |
|
| 46 | 2 | return false; |
|
| 47 | } |
||
| 48 | |||
| 49 | 6 | if ($feature->getRole()) { |
|
| 50 | 4 | if (!$this->context->isGranted($feature->getRole())) { |
|
| 51 | return false; |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | 6 | if ('' !== trim($feature->getParentRole())) { |
|
| 56 | 2 | if (!$this->context->isGranted($feature->getParentRole())) { |
|
| 57 | 2 | return false; |
|
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | 4 | return true; |
|
| 62 | } |
||
| 64 |