| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3.0987 |
| Changes | 0 | ||
| 1 | <?php |
||
| 42 | 1 | private function filter(array $keys, array $parameters) |
|
| 43 | { |
||
| 44 | 1 | if ($keys === ['*']) { |
|
| 45 | return $parameters; |
||
| 46 | } |
||
| 47 | |||
| 48 | 1 | $errorKeys = array_keys(array_diff(array_values($keys), array_keys($parameters))); |
|
| 49 | 1 | if ($errorKeys) { |
|
|
|
|||
| 50 | throw new \LogicException(implode(',', $errorKeys)); |
||
| 51 | } |
||
| 52 | |||
| 53 | 1 | return array_filter((array) $parameters, function($key) use ($keys) { |
|
| 54 | 1 | return in_array($key, $keys); |
|
| 55 | 1 | }, ARRAY_FILTER_USE_KEY); |
|
| 56 | } |
||
| 57 | } |
||
| 58 |
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.