| Conditions | 6 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | function associativeFlatten(iterable $array, string $prepend = ''): iterable |
||
| 17 | { |
||
| 18 | $results = []; |
||
| 19 | |||
| 20 | if (Arr::isAssoc((array) $array)) { |
||
| 21 | foreach ($array as $key => $value) { |
||
| 22 | if (is_iterable($value) && ! empty($value)) { |
||
| 23 | $dot = ''; |
||
| 24 | if (Arr::isAssoc($value)) { |
||
| 25 | $dot = '.'; |
||
| 26 | } |
||
| 27 | $results = array_merge($results, associativeFlatten($value, $prepend . $key . $dot)); |
||
| 28 | |||
| 29 | continue; |
||
| 30 | } |
||
| 31 | $results[$prepend . $key] = $value; |
||
| 32 | } |
||
| 33 | return $results; |
||
| 34 | } |
||
| 35 | $results[$prepend] = $array; |
||
| 36 | return $results; |
||
| 37 | } |
||
| 39 |