Conditions | 10 |
Paths | 11 |
Total Lines | 23 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 10 |
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 |
||
39 | 2 | protected function processException(\Throwable $e): void |
|
40 | { |
||
41 | 2 | if ($this->throwOnError) { |
|
42 | 1 | throw $e; |
|
43 | } |
||
44 | 1 | if (\defined('APP_DEBUG') && APP_DEBUG) { |
|
45 | 1 | $hasDumpFunction = \function_exists('dump'); |
|
46 | 1 | if (\defined('DEBUG_DUMP_EXCEPTION') && DEBUG_DUMP_EXCEPTION) { |
|
47 | 1 | $exceptionMessage = '[' . \get_class($e) . '] ' . $e->getMessage(); |
|
48 | 1 | if ($hasDumpFunction) { |
|
49 | 1 | dump($exceptionMessage, $e->getTraceAsString()); |
|
50 | } else { |
||
51 | // @codeCoverageIgnoreStart |
||
52 | var_dump($exceptionMessage, $e->getTraceAsString()); |
||
1 ignored issue
–
show
|
|||
53 | // @codeCoverageIgnoreEnd |
||
54 | } |
||
55 | } |
||
56 | 1 | if (\defined('DEBUG_DUMP_EXCEPTION_CLASS') && DEBUG_DUMP_EXCEPTION_CLASS) { |
|
57 | 1 | if ($hasDumpFunction) { |
|
58 | 1 | dump($e); |
|
59 | } else { |
||
60 | // @codeCoverageIgnoreStart |
||
61 | var_dump($e); |
||
62 | // @codeCoverageIgnoreEnd |
||
68 |