| Conditions | 11 |
| Paths | 11 |
| Total Lines | 26 |
| Code Lines | 23 |
| 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 |
||
| 61 | public function toLogLevelValue(string $level) |
||
| 62 | { |
||
| 63 | switch (strtolower($level)) { |
||
| 64 | case 'debug': |
||
| 65 | return 1; |
||
| 66 | case 'info': |
||
| 67 | return 2; |
||
| 68 | case 'notice': // PSR-3 |
||
| 69 | return 3; |
||
| 70 | case 'warn': |
||
| 71 | case 'warning': // PSR-3 |
||
| 72 | return 4; |
||
| 73 | case 'error': |
||
| 74 | return 5; |
||
| 75 | case 'critical': // PSR-3 |
||
| 76 | return 6; |
||
| 77 | case 'alert': // PSR-3 |
||
| 78 | return 7; |
||
| 79 | case 'emergency': // PSR-3 |
||
| 80 | return 8; |
||
| 81 | case 'fatal': |
||
| 82 | return 9; |
||
| 83 | default: |
||
| 84 | throw new LoggerException("Undefined log level: $level"); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 98 |