| Conditions | 13 |
| Paths | 13 |
| Total Lines | 20 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 79 | private static function _style($name, $value) { |
||
| 80 | switch($name) { |
||
| 81 | case 'color': |
||
| 82 | return self::_color($value); |
||
| 83 | case 'background': |
||
| 84 | return self::_color($value, true); |
||
| 85 | case 'bold': |
||
| 86 | return $value ? 1 : 21; |
||
| 87 | case 'dim': |
||
| 88 | return $value ? 2 : 22; |
||
| 89 | case 'underline': |
||
| 90 | return $value ? 4 : 24; |
||
| 91 | case 'blink': |
||
| 92 | return $value ? 5 : 25; |
||
| 93 | case 'invert': |
||
| 94 | return $value ? 7 : 27; |
||
| 95 | } |
||
| 96 | |||
| 97 | return null; |
||
| 98 | } |
||
| 99 | |||
| 111 | } |