| Conditions | 10 |
| Paths | 10 |
| Total Lines | 24 |
| 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 |
||
| 23 | * @link https://github.com/laravel/framework/blob/5.2/src/Illuminate/Foundation/helpers.php#L369 |
||
| 24 | */ |
||
| 25 | function env($key, $default = null) |
||
| 26 | { |
||
| 27 | $value = getenv($key); |
||
| 28 | if ($value === false) { |
||
| 29 | return $default; |
||
| 30 | } |
||
| 31 | |||
| 32 | switch (strtolower($value)) { |
||
| 33 | case 'true': |
||
| 34 | case '(true)': |
||
| 35 | return true; |
||
| 36 | case 'false': |
||
| 37 | case '(false)': |
||
| 38 | return false; |
||
| 39 | case 'empty': |
||
| 40 | case '(empty)': |
||
| 41 | return ''; |
||
| 42 | case 'null': |
||
| 43 | case '(null)': |
||
| 44 | return null; |
||
| 45 | } |
||
| 46 | |||
| 47 | return trim($value); |
||
| 67 |