Conditions | 1 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
25 | function array_path_set(array $config, string $dotPath, $value): array |
||
26 | { |
||
27 | // Work backward from the last key, wrapping each key in an array |
||
28 | 3 | $replace = array_reduce( |
|
29 | 3 | array_reverse(explode('.', $dotPath)), |
|
30 | function ($value, $key) { |
||
31 | 3 | return [$key => $value]; |
|
32 | 3 | }, |
|
33 | 3 | $value |
|
34 | ); |
||
35 | |||
36 | // Overwrite the array with the replacement |
||
37 | 3 | return array_replace_recursive($config, $replace); |
|
38 | } |
||
39 |