| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function shouldHaveAccess(Request $request) |
||
| 31 | { |
||
| 32 | $countries = $this->getCountries(); |
||
| 33 | $strategy = $this->getStrategy(); |
||
| 34 | |||
| 35 | if (!$countries) { |
||
|
|
|||
| 36 | return $strategy !== 'allow'; |
||
| 37 | } |
||
| 38 | |||
| 39 | $requestCountry = Location::get($request->ip())->countryCode; |
||
| 40 | |||
| 41 | if ($strategy === 'allow') { |
||
| 42 | return in_array($requestCountry, $countries); |
||
| 43 | } |
||
| 44 | |||
| 45 | return !in_array($requestCountry, $countries); |
||
| 46 | } |
||
| 48 |
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.