| Conditions | 31 |
| Paths | 508 |
| Total Lines | 134 |
| Code Lines | 98 |
| Lines | 3 |
| Ratio | 2.24 % |
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 |
||
| 76 | /** |
||
| 77 | * Un-camelizes a string. |
||
| 78 | * |
||
| 79 | * @param $name |
||
| 80 | * The string to underscore. |
||
| 81 | * |
||
| 82 | * @return string |
||
| 83 | * The underscored string. |
||
| 84 | * |
||
| 85 | */ |
||
| 86 | public static function underscore($name) { |
||
| 87 | return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name)); |
||
| 88 | } |
||
| 89 | } |
||
| 90 |