Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
21 | 2 | public static function flatMap(array $array, callable $callback): array |
|
22 | { |
||
23 | 2 | $mapped = self::map($array, $callback); |
|
24 | |||
25 | 2 | $flattened = []; |
|
26 | |||
27 | 2 | foreach ($mapped as $item) { |
|
28 | 2 | if (is_array($item)) { |
|
29 | 2 | $flattened = array_merge($flattened, $item); |
|
30 | } else { |
||
31 | 2 | $flattened[] = $item; |
|
32 | } |
||
33 | } |
||
34 | |||
35 | 2 | return $flattened; |
|
36 | } |
||
37 | |||
65 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.