| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 4 | public function flatMap(callable $callback): self |
|
| 18 | { |
||
| 19 | 4 | $flattened = []; |
|
| 20 | 4 | foreach ($this->array as $index => $element) { |
|
| 21 | 3 | $transformation = $callback($element, $index); |
|
| 22 | 3 | if (is_array($transformation)) { |
|
| 23 | 3 | array_push($flattened, ...$transformation); |
|
| 24 | } else { |
||
| 25 | 1 | $flattened[] = $transformation; |
|
| 26 | } |
||
| 27 | } |
||
| 28 | 4 | $this->array = $flattened; |
|
| 29 | |||
| 30 | 4 | return $this; |
|
| 31 | } |
||
| 33 |