| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 13 | public static function flatMap(array $array, callable $callback): array |
|
| 22 | { |
||
| 23 | 13 | $mapped = self::map($array, $callback); |
|
| 24 | |||
| 25 | 13 | $flattened = []; |
|
| 26 | |||
| 27 | 13 | foreach ($mapped as $item) { |
|
| 28 | 13 | if (is_array($item)) { |
|
| 29 | 13 | $flattened = array_merge($flattened, $item); |
|
| 30 | } else { |
||
| 31 | 13 | $flattened[] = $item; |
|
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | 13 | 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
@returnannotation as described here.