| Conditions | 16 |
| Paths | 16 |
| Total Lines | 32 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 27 |
| CRAP Score | 16 |
| 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 |
||
| 52 | 50 | protected function codeToString($code) |
|
| 53 | { |
||
| 54 | switch ($code) { |
||
| 55 | 50 | case E_ERROR: |
|
| 56 | 48 | case E_USER_ERROR: |
|
| 57 | 46 | case E_RECOVERABLE_ERROR: |
|
| 58 | 14 | return 'Fatal error'; |
|
| 59 | 36 | case E_WARNING: |
|
| 60 | 33 | case E_USER_WARNING: |
|
| 61 | 8 | return 'Warning'; |
|
| 62 | 28 | case E_PARSE: |
|
| 63 | 4 | return 'Parse error'; |
|
| 64 | 24 | case E_NOTICE: |
|
| 65 | 22 | case E_USER_NOTICE: |
|
| 66 | 6 | return 'Notice'; |
|
| 67 | 18 | case E_CORE_ERROR: |
|
| 68 | 2 | return 'Core error'; |
|
| 69 | 16 | case E_CORE_WARNING: |
|
| 70 | 2 | return 'Core warning'; |
|
| 71 | 14 | case E_COMPILE_ERROR: |
|
| 72 | 2 | return 'Compile error'; |
|
| 73 | 12 | case E_COMPILE_WARNING: |
|
| 74 | 2 | return 'Compile warning'; |
|
| 75 | 10 | case E_STRICT: |
|
| 76 | 4 | return 'Strict standards'; |
|
| 77 | 6 | case E_DEPRECATED: |
|
| 78 | 5 | case E_USER_DEPRECATED: |
|
| 79 | 4 | return 'Deprecated'; |
|
| 80 | } |
||
| 81 | |||
| 82 | 2 | return 'Unknown error'; |
|
| 83 | } |
||
| 84 | } |