| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3.0261 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 60 | protected function shouldHaveAccess(array $countries, string $strategy) |
|
| 18 | { |
||
| 19 | 60 | if (!$countries) { |
|
|
|
|||
| 20 | 36 | return $strategy !== 'allow'; |
|
| 21 | } |
||
| 22 | |||
| 23 | 24 | $requestCountry = Location::get()->countryCode; |
|
| 24 | |||
| 25 | 24 | if ($strategy === 'allow') { |
|
| 26 | return in_array($requestCountry, $countries); |
||
| 27 | } |
||
| 28 | |||
| 29 | 24 | return !in_array($requestCountry, $countries); |
|
| 30 | } |
||
| 32 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.