| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 80 | protected function shouldHaveAccess(Request $request, array $countries, string $strategy) |
|
| 19 | { |
||
| 20 | 80 | if (!$countries) { |
|
|
|
|||
| 21 | 30 | return $strategy !== 'allow'; |
|
| 22 | } |
||
| 23 | |||
| 24 | 80 | $requestCountry = Location::get($request->ip())->countryCode; |
|
| 25 | |||
| 26 | 80 | if ($strategy === 'allow') { |
|
| 27 | 50 | return in_array($requestCountry, $countries); |
|
| 28 | } |
||
| 29 | |||
| 30 | 30 | return !in_array($requestCountry, $countries); |
|
| 31 | } |
||
| 33 |
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.