| Conditions | 10 |
| Paths | 10 |
| Total Lines | 21 |
| Code 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 |
||
| 13 | function smarty_function_season($params, &$smarty) |
||
|
|
|||
| 14 | { |
||
| 15 | $season = date('z'); |
||
| 16 | if (isset($params['season'])) { |
||
| 17 | $season = $params['season']; |
||
| 18 | } |
||
| 19 | |||
| 20 | if ($season <= 81 || $season >= 355) { |
||
| 21 | return $params['winter']; |
||
| 22 | } |
||
| 23 | |||
| 24 | if ($season >= 82 && $season <= 173) { |
||
| 25 | return $params['spring']; |
||
| 26 | } |
||
| 27 | if ($season >= 174 && $season <= 264) { |
||
| 28 | return $params['summer']; |
||
| 29 | } |
||
| 30 | if ($season >= 265 && $season <= 354) { |
||
| 31 | return $params['autumn']; |
||
| 32 | } |
||
| 33 | } |
||
| 34 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.