Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public static function flatMap(array $array, callable $callback): array |
||
17 | { |
||
18 | $mapped = self::map($array, $callback); |
||
19 | |||
20 | $flattened = []; |
||
21 | |||
22 | foreach ($mapped as $item) { |
||
23 | if (is_array($item)) { |
||
24 | $flattened = array_merge($flattened, $item); |
||
25 | } else { |
||
26 | $flattened[] = $item; |
||
27 | } |
||
28 | } |
||
29 | |||
30 | return $flattened; |
||
31 | } |
||
32 | |||
60 |