| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Code Lines | 37 |
| 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 |
||
| 36 | public function provideData_basicTraversal() |
||
| 37 | { |
||
| 38 | $text1 = 'lorem ipsum'; |
||
| 39 | $words1 = explode(' ', $text1); |
||
| 40 | |||
| 41 | $text2 = 'dolor'; |
||
| 42 | $words2 = explode(' ', $text2); |
||
| 43 | |||
| 44 | $text3 = 'sit amet malef'; |
||
| 45 | $words3 = explode(' ', 'sit amet malef'); |
||
| 46 | |||
| 47 | $text4 = 'dolor sit'; |
||
| 48 | $words4 = explode(' ', $text4); |
||
| 49 | |||
| 50 | $foo1 = new Foo( |
||
| 51 | $bar1 = new Bar([ |
||
| 52 | $baz1 = new Baz($text1), |
||
| 53 | $baz2 = new Baz($text2), |
||
| 54 | ]) |
||
| 55 | ); |
||
| 56 | |||
| 57 | $foo2 = new Foo( |
||
| 58 | $bar2 = new Bar([ |
||
| 59 | $baz1, |
||
| 60 | $baz3 = new Baz($text3), |
||
| 61 | $baz4 = new Baz($text4), |
||
| 62 | ]) |
||
| 63 | ); |
||
| 64 | |||
| 65 | $foo3 = new Foo(); |
||
| 66 | |||
| 67 | return [ |
||
| 68 | [ |
||
| 69 | [$foo1, $foo2, $foo3], |
||
| 70 | ['bar'], |
||
| 71 | [$bar1, $bar2], |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | [$bar1, $bar2], |
||
| 75 | ['bazs'], |
||
| 76 | [$baz1, $baz2, $baz3, $baz4], |
||
| 77 | ], |
||
| 78 | [ |
||
| 79 | [$foo1, $foo2, $foo3], |
||
| 80 | ['bar', 'bazs'], |
||
| 81 | [$baz1, $baz2, $baz3, $baz4], |
||
| 82 | ], |
||
| 83 | [ |
||
| 84 | [$foo1, $foo2, $foo3], |
||
| 85 | ['bar', 'bazs', 'text'], |
||
| 86 | [$text1, $text2, $text3, $text4], |
||
| 87 | ], |
||
| 88 | [ |
||
| 89 | [$foo1, $foo2, $foo3], |
||
| 90 | ['bar', 'bazs', 'words'], |
||
| 91 | array_merge($words1, $words2, $words3, $words4), |
||
| 92 | ], |
||
| 93 | [ |
||
| 94 | [$foo1, $foo2, $foo3], |
||
| 95 | ['bar', 'bazs', 'textStats', '[wordCount]'], |
||
| 96 | [count($words1), count($words2), count($words3), count($words4)], |
||
| 97 | ], |
||
| 141 |