Conditions | 11 |
Paths | 12 |
Total Lines | 32 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
31 | public static function torow(mixed $array, mixed $ignore = 0, mixed $byColumn = false): array|string |
||
32 | { |
||
33 | if (!is_numeric($ignore)) { |
||
34 | return ExcelError::VALUE(); |
||
35 | } |
||
36 | $ignore = (int) $ignore; |
||
37 | if ($ignore < 0 || $ignore > 3) { |
||
38 | return ExcelError::VALUE(); |
||
39 | } |
||
40 | if (is_int($byColumn) || is_float($byColumn)) { |
||
41 | $byColumn = (bool) $byColumn; |
||
42 | } |
||
43 | if (!is_bool($byColumn)) { |
||
44 | return ExcelError::VALUE(); |
||
45 | } |
||
46 | if (!is_array($array)) { |
||
47 | $array = [$array]; |
||
48 | } |
||
49 | if ($byColumn) { |
||
50 | $temp = []; |
||
51 | foreach ($array as $row) { |
||
52 | if (!is_array($row)) { |
||
53 | $row = [$row]; |
||
54 | } |
||
55 | $temp[] = Functions::flattenArray($row); |
||
56 | } |
||
57 | $array = ChooseRowsEtc::transpose($temp); |
||
58 | } else { |
||
59 | $array = Functions::flattenArray($array); |
||
60 | } |
||
61 | |||
62 | return self::byRow($array, $ignore); |
||
63 | } |
||
95 |