| Conditions | 7 |
| Paths | 9 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 7.4822 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | 4 | public function isGranted(Feature $feature) |
|
| 31 | { |
||
| 32 | 4 | if (null === $this->context) { |
|
| 33 | return false; |
||
| 34 | } |
||
| 35 | |||
| 36 | 4 | if (!$feature->isEnabled()) { |
|
| 37 | 1 | return false; |
|
| 38 | } |
||
| 39 | |||
| 40 | 3 | if ($feature->getRole()) { |
|
| 41 | 2 | if (!$this->context->isGranted($feature->getRole())) { |
|
| 42 | return false; |
||
| 43 | } |
||
| 44 | 2 | } |
|
| 45 | |||
| 46 | 3 | if ($feature->getParentRole()) { |
|
|
|
|||
| 47 | 1 | if (!$this->context->isGranted($feature->getParentRole())) { |
|
| 48 | 1 | return false; |
|
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | 2 | return true; |
|
| 53 | } |
||
| 54 | } |
||
| 55 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: