Conditions | 10 |
Paths | 13 |
Total Lines | 23 |
Code Lines | 14 |
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 |
||
70 | private static function byRow(array $array, int $ignore): array |
||
71 | { |
||
72 | $returnMatrix = []; |
||
73 | foreach ($array as $row) { |
||
74 | if (!is_array($row)) { |
||
75 | $row = [$row]; |
||
76 | } |
||
77 | foreach ($row as $cell) { |
||
78 | if ($cell === null) { |
||
79 | if ($ignore === 1 || $ignore === 3) { |
||
80 | continue; |
||
81 | } |
||
82 | $cell = 0; |
||
83 | } elseif (ErrorValue::isError($cell)) { |
||
84 | if ($ignore === 2 || $ignore === 3) { |
||
85 | continue; |
||
86 | } |
||
87 | } |
||
88 | $returnMatrix[] = $cell; |
||
89 | } |
||
90 | } |
||
91 | |||
92 | return $returnMatrix; |
||
93 | } |
||
95 |