Conditions | 6 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | public function __invoke(array $target, array ...$args): array |
||
11 | { |
||
12 | [$key, $subkey] = $args[0]; |
||
13 | |||
14 | if (isset($target[$key]) && is_array($target[$key])) { |
||
15 | $target[$key][$subkey] = $target[$key]; |
||
16 | return $target; |
||
17 | } |
||
18 | |||
19 | if (is_object($target[$key])) { |
||
20 | $getter = "get" . Inflect::camelize(ucfirst((string) $subkey)); |
||
21 | if (method_exists($target[$key], $getter)) { |
||
22 | $target[$key][$subkey] = $target[$key]->$getter(); |
||
23 | } |
||
24 | return $target; |
||
25 | } |
||
26 | |||
27 | if (isset($target[$key])) { |
||
28 | $old_value = $target[$key]; |
||
29 | unset($target[$key]); |
||
30 | |||
31 | $target[$key][$subkey] = $old_value; |
||
32 | return $target; |
||
33 | } |
||
34 | |||
35 | return $target; |
||
36 | } |
||
38 |