| Conditions | 11 |
| Paths | 11 |
| Total Lines | 26 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 21 |
| CRAP Score | 11.0113 |
| 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 |
||
| 39 | 141 | public function toLogLevelValue(string $level) |
|
| 40 | { |
||
| 41 | 141 | switch (strtolower($level)) { |
|
| 42 | 141 | case 'debug': |
|
| 43 | 28 | return 1; |
|
| 44 | 113 | case 'info': |
|
| 45 | 25 | return 2; |
|
| 46 | 88 | case 'notice': // PSR-3 |
|
| 47 | 11 | return 3; |
|
| 48 | 77 | case 'warn': |
|
| 49 | 66 | case 'warning': // PSR-3 |
|
| 50 | 22 | return 4; |
|
| 51 | 55 | case 'error': |
|
| 52 | 11 | return 5; |
|
| 53 | 44 | case 'critical': // PSR-3 |
|
| 54 | 11 | return 6; |
|
| 55 | 33 | case 'alert': // PSR-3 |
|
| 56 | 11 | return 7; |
|
| 57 | 22 | case 'emergency': // PSR-3 |
|
| 58 | 11 | return 8; |
|
| 59 | 11 | case 'fatal': |
|
| 60 | 11 | return 9; |
|
| 61 | default: |
||
| 62 | throw new LoggerException("Undefined log level: $level"); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 |