| Conditions | 13 |
| Paths | 13 |
| Total Lines | 27 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 13 |
| 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 |
||
| 18 | 62 | protected function getLogLevel($code = null) |
|
| 19 | { |
||
| 20 | switch ($code) { |
||
| 21 | 62 | case E_STRICT: |
|
| 22 | 60 | case E_DEPRECATED: |
|
| 23 | 59 | case E_USER_DEPRECATED: |
|
| 24 | 8 | return LogLevel::INFO; |
|
| 25 | |||
| 26 | 54 | case E_NOTICE: |
|
| 27 | 52 | case E_USER_NOTICE: |
|
| 28 | 6 | return LogLevel::NOTICE; |
|
| 29 | |||
| 30 | 48 | case E_WARNING: |
|
| 31 | 45 | case E_CORE_WARNING: |
|
| 32 | 44 | case E_COMPILE_WARNING: |
|
| 33 | 43 | case E_USER_WARNING: |
|
| 34 | 12 | return LogLevel::WARNING; |
|
| 35 | |||
| 36 | 36 | case E_PARSE: |
|
| 37 | 34 | case E_CORE_ERROR: |
|
| 38 | 33 | case E_COMPILE_ERROR: |
|
| 39 | 8 | return LogLevel::CRITICAL; |
|
| 40 | |||
| 41 | 14 | default: |
|
| 42 | 28 | return LogLevel::ERROR; |
|
| 43 | 14 | } |
|
| 44 | } |
||
| 45 | |||
| 84 | } |