| Conditions | 10 |
| Paths | 2 |
| Total Lines | 14 |
| 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 |
||
| 13 | function mime($type) |
||
| 14 | { |
||
| 15 | if ($type == 'jpg' || |
||
| 16 | $type == 'png' || |
||
| 17 | $type == 'jpeg' || |
||
| 18 | $type == 'gif' || |
||
| 19 | $type == 'image/jpeg' || |
||
| 20 | $type == 'image/jpg' || |
||
| 21 | $type == 'image/gif' || |
||
| 22 | $type == 'image/png' || |
||
| 23 | starts_with($type, 'image')) { |
||
| 24 | return 'image'; |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 57 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.