Conditions | 5 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public static function validate(array $responseFormats): array |
||
18 | { |
||
19 | if ( |
||
20 | $responseFormats |
||
|
|||
21 | && is_array($responseFormats) |
||
22 | && count($responseFormats) > 0 |
||
23 | ) { |
||
24 | return array_map(static function (string $class) { |
||
25 | if (! is_a($class, FoaasResponse::class, true)) { |
||
26 | throw new InvalidResponse('A class needs to implement \'Codeat3\FoaasClient\Response\FoaasResponse\''); |
||
27 | } |
||
28 | |||
29 | return $class; |
||
30 | }, $responseFormats); |
||
31 | } |
||
32 | |||
33 | return []; |
||
34 | } |
||
36 |
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.