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 |
||
50 | 7 | private function resolveLogLevel(Throwable $e) |
|
51 | { |
||
52 | 7 | if ($e instanceof \ErrorException) { |
|
1 ignored issue
–
show
|
|||
53 | 4 | switch ($e->getSeverity()) { |
|
54 | 4 | case E_ERROR: |
|
55 | 4 | case E_RECOVERABLE_ERROR: |
|
56 | 4 | case E_CORE_ERROR: |
|
57 | 3 | case E_COMPILE_ERROR: |
|
58 | 3 | case E_USER_ERROR: |
|
59 | 3 | case E_PARSE: |
|
60 | 1 | return LogLevel::ERROR; |
|
61 | 3 | case E_WARNING: |
|
62 | 3 | case E_USER_WARNING: |
|
63 | 2 | case E_CORE_WARNING: |
|
64 | 2 | case E_COMPILE_WARNING: |
|
65 | 1 | return LogLevel::WARNING; |
|
66 | 2 | case E_NOTICE: |
|
67 | 1 | case E_USER_NOTICE: |
|
68 | 1 | case E_STRICT: |
|
69 | 1 | case E_DEPRECATED: |
|
70 | case E_USER_DEPRECATED: |
||
71 | 2 | return LogLevel::NOTICE; |
|
72 | default: |
||
73 | break; |
||
74 | } |
||
75 | } |
||
76 | |||
77 | 3 | return LogLevel::ERROR; |
|
78 | } |
||
79 | } |
||
80 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.