| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 59 | 14 | public static function setValue(array $array, $key, $value) |
|
| 60 | { |
||
| 61 | 14 | if (($pos = strpos($key, '.')) !== false) { |
|
| 62 | 11 | $left_key = substr($key, 0, $pos); |
|
| 63 | 11 | $right_key = substr($key, $pos + 1); |
|
| 64 | |||
| 65 | 11 | if (isset($array[$left_key])) { |
|
| 66 | 7 | $data = $array[$left_key]; |
|
| 67 | 7 | if (!is_array($data)) { |
|
| 68 | 7 | $data = [$data]; |
|
| 69 | } |
||
| 70 | } else { |
||
| 71 | 4 | $data = []; |
|
| 72 | } |
||
| 73 | |||
| 74 | 11 | $array[$left_key] = static::setValue($data, $right_key, $value); |
|
| 75 | } else { |
||
| 76 | 14 | $array[$key] = $value; |
|
| 77 | } |
||
| 78 | |||
| 79 | 14 | return $array; |
|
| 80 | } |
||
| 81 | } |