| Conditions | 14 |
| Paths | 6 |
| Total Lines | 22 |
| 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 |
||
| 18 | function testRuleApplyToNestedLoops() |
||
| 19 | { |
||
| 20 | $foo = 'foo'; |
||
| 21 | |||
| 22 | for ($i = 0; sizeof($i) < 5 || $i < 5; $i++) { |
||
| 23 | while ($i !== 'baz' && count($foo) || $i < 5) { |
||
|
|
|||
| 24 | $foo .= $i; |
||
| 25 | do { |
||
| 26 | $i += 2; |
||
| 27 | } while (5 - 0 < sizeof($foo) && 3 < $foo . 'bar'); |
||
| 28 | while (count($foo) < 5 && sizeof($foo) < 5 && count($foo) < 5) { |
||
| 29 | while (count($_GET) > -1 && 0) { |
||
| 30 | for ($j = 0; $j < count($_GET); $j++) { |
||
| 31 | $i += $j * 2; |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return $foo; |
||
| 39 | } |
||
| 40 |