| Conditions | 10 |
| Paths | 10 |
| Total Lines | 27 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 57 | public static function get($key, $default = null) |
||
| 58 | { |
||
| 59 | $value = static::getRepositoryCreator()->get($key); |
||
| 60 | |||
| 61 | if ($value === false) |
||
| 62 | { |
||
| 63 | return value($default); |
||
| 64 | } |
||
| 65 | |||
| 66 | // Handle any boolean values |
||
| 67 | switch (strtolower($value)) |
||
| 68 | { |
||
| 69 | case 'true': |
||
| 70 | case '(true)': |
||
| 71 | return true; |
||
| 72 | case 'false': |
||
| 73 | case '(false)': |
||
| 74 | return false; |
||
| 75 | case 'empty': |
||
| 76 | case '(empty)': |
||
| 77 | return ''; |
||
| 78 | case 'null': |
||
| 79 | case '(null)': |
||
| 80 | return null; |
||
| 81 | } |
||
| 82 | |||
| 83 | return $value; |
||
| 84 | } |
||
| 105 | } |