| Conditions | 10 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 9 |
| 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 |
||
| 82 | public static function getSwitch($name, $state) { |
||
| 83 | |||
| 84 | if(isset($_ENV[$name])) { |
||
| 85 | |||
| 86 | $val = strtolower(trim($_ENV[$name])); |
||
| 87 | if($state == self::SWITCH_STATE_ON) { |
||
| 88 | if($val === self::SWITCH_STATE_ON || $val === '1' || $val === 'true') { |
||
| 89 | return true; |
||
| 90 | } |
||
| 91 | } else if($state == self::SWITCH_STATE_OFF) { |
||
| 92 | if($val === self::SWITCH_STATE_OFF || $val === '0' || $val === 'false') { |
||
| 93 | return true; |
||
| 94 | } |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | return false; |
||
| 99 | } |
||
| 100 | } |