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