Conditions | 7 |
Paths | 21 |
Total Lines | 27 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 7 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | 3 | public static function vstack(mixed ...$inputData): array|string |
|
15 | { |
||
16 | 3 | $returnMatrix = []; |
|
17 | |||
18 | 3 | $columns = 0; |
|
19 | 3 | foreach ($inputData as $matrix) { |
|
20 | 3 | if (!is_array($matrix)) { |
|
21 | 1 | $count = 1; |
|
22 | } else { |
||
23 | 3 | $count = count(reset($matrix)); //* @phpstan-ignore-line |
|
24 | } |
||
25 | 3 | $columns = max($columns, $count); |
|
26 | } |
||
27 | |||
28 | 3 | foreach ($inputData as $matrix) { |
|
29 | 3 | if (!is_array($matrix)) { |
|
30 | 1 | $matrix = [$matrix]; |
|
31 | } |
||
32 | 3 | foreach ($matrix as $row) { |
|
33 | 3 | if (!is_array($row)) { |
|
34 | 1 | $row = [$row]; |
|
35 | } |
||
36 | 3 | $returnMatrix[] = array_values(array_pad($row, $columns, ExcelError::NA())); |
|
37 | } |
||
38 | } |
||
39 | |||
40 | 3 | return $returnMatrix; |
|
41 | } |
||
43 |