| Conditions | 7 |
| Paths | 6 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public static function setNodes(array $data, array &$array): void |
||
| 21 | { |
||
| 22 | $separator = '|'; |
||
| 23 | foreach ($data as $name => $value) { |
||
| 24 | if (false === mb_strpos($name, $separator)) { |
||
| 25 | $array[$name] = $value; |
||
| 26 | } else { |
||
| 27 | $keys = explode($separator, $name); |
||
| 28 | $optTree = &$array; |
||
| 29 | while (($key = array_shift($keys))) { |
||
| 30 | if ($keys) { |
||
|
|
|||
| 31 | if (!isset($optTree[$key]) || !\is_array($optTree[$key])) { |
||
| 32 | $optTree[$key] = []; |
||
| 33 | } |
||
| 34 | $optTree = &$optTree[$key]; |
||
| 35 | } else { |
||
| 36 | $optTree[$key] = $value; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 63 |
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.