| Conditions | 25 |
| Paths | 512 |
| Total Lines | 12 |
| 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 |
||
| 22 | function doSomething() |
||
|
|
|||
| 23 | { |
||
| 24 | if (true) {} |
||
| 25 | if (true) {} |
||
| 26 | if (true) {} |
||
| 27 | if (true) {} |
||
| 28 | if (true && true && true && true) {} |
||
| 29 | if (true && true && true && true) {} |
||
| 30 | if (true && true && true && true) {} |
||
| 31 | if (true && true && true && true) {} |
||
| 32 | if (true && true && true && true) {} |
||
| 33 | } |
||
| 34 | } |
||
| 36 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.