| Conditions | 17 |
| Paths | 17 |
| Total Lines | 29 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 21 |
| CRAP Score | 17.1903 |
| 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 |
||
| 67 | 7 | private function resolveLogLevel(Throwable $e) |
|
| 68 | { |
||
| 69 | 7 | if ($e instanceof \ErrorException) { |
|
| 70 | 4 | switch ($e->getSeverity()) { |
|
| 71 | 4 | case E_ERROR: |
|
| 72 | 4 | case E_RECOVERABLE_ERROR: |
|
| 73 | 4 | case E_CORE_ERROR: |
|
| 74 | 3 | case E_COMPILE_ERROR: |
|
| 75 | 3 | case E_USER_ERROR: |
|
| 76 | 3 | case E_PARSE: |
|
| 77 | 1 | return LogLevel::ERROR; |
|
| 78 | 3 | case E_WARNING: |
|
| 79 | 3 | case E_USER_WARNING: |
|
| 80 | 2 | case E_CORE_WARNING: |
|
| 81 | 2 | case E_COMPILE_WARNING: |
|
| 82 | 1 | return LogLevel::WARNING; |
|
| 83 | 2 | case E_NOTICE: |
|
| 84 | 1 | case E_USER_NOTICE: |
|
| 85 | 1 | case E_STRICT: |
|
| 86 | 1 | case E_DEPRECATED: |
|
| 87 | case E_USER_DEPRECATED: |
||
| 88 | 2 | return LogLevel::NOTICE; |
|
| 89 | default: |
||
| 90 | break; |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | 3 | return LogLevel::ERROR; |
|
| 95 | } |
||
| 96 | } |
||
| 97 |