| Conditions | 16 |
| Paths | 16 |
| Total Lines | 30 |
| Code Lines | 23 |
| 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 |
||
| 43 | private function translateError(\ErrorException $exception): string |
||
| 44 | { |
||
| 45 | switch ($exception->getSeverity()) { |
||
| 46 | case E_ERROR: |
||
| 47 | case E_RECOVERABLE_ERROR: |
||
| 48 | case E_CORE_ERROR: |
||
| 49 | case E_COMPILE_ERROR: |
||
| 50 | case E_USER_ERROR: |
||
| 51 | case E_PARSE: |
||
| 52 | return LogLevel::ERROR; |
||
| 53 | |||
| 54 | case E_WARNING: |
||
| 55 | case E_USER_WARNING: |
||
| 56 | case E_CORE_WARNING: |
||
| 57 | case E_COMPILE_WARNING: |
||
| 58 | return LogLevel::WARNING; |
||
| 59 | |||
| 60 | case E_NOTICE: |
||
| 61 | case E_USER_NOTICE: |
||
| 62 | return LogLevel::NOTICE; |
||
| 63 | |||
| 64 | case E_STRICT: |
||
| 65 | case E_DEPRECATED: |
||
| 66 | case E_USER_DEPRECATED: |
||
| 67 | return LogLevel::INFO; |
||
| 68 | |||
| 69 | default: |
||
| 70 | return LogLevel::CRITICAL; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | } |
||
| 74 |