Conditions | 10 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
66 | protected function _printDiff($c, $s1, $s2, $i, $j) |
||
67 | { |
||
68 | $diff = ''; |
||
69 | if ($i >= 0 && $j >= 0 && $s1[$i] === $s2[$j]) { |
||
70 | $diff .= $this->_printDiff($c, $s1, $s2, $i - 1, $j - 1); |
||
71 | $diff .= ' ' . $s1[$i] . PHP_EOL; |
||
72 | } else { |
||
73 | if ($j >= 0 && ($i === -1 || $c[$i][$j - 1] >= $c[$i - 1][$j])) { |
||
74 | $diff .= $this->_printDiff($c, $s1, $s2, $i, $j - 1); |
||
75 | $diff .= '+ ' . $s2[$j] . PHP_EOL; |
||
76 | } elseif ($i >= 0 && ($j === -1 || $c[$i][$j - 1] < $c[$i - 1][$j])) { |
||
77 | $diff .= $this->_printDiff($c, $s1, $s2, $i - 1, $j); |
||
78 | $diff .= '- ' . $s1[$i] . PHP_EOL; |
||
79 | } |
||
80 | } |
||
81 | |||
82 | return $diff; |
||
83 | } |
||
84 | |||
101 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: