Conditions | 11 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 132 |
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 |
||
37 | public static function translate(\Exception $e): \Exception |
||
38 | { |
||
39 | if ($e instanceof \MongoDB\Driver\Exception\ConnectionException || |
||
1 ignored issue
–
show
|
|||
40 | $e instanceof \MongoDB\Driver\Exception\ExecutionTimeoutException) { |
||
1 ignored issue
–
show
|
|||
41 | return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e); |
||
42 | } elseif ($e instanceof \MongoDB\Driver\Exception\InvalidArgumentException || |
||
1 ignored issue
–
show
|
|||
43 | $e instanceof \MongoDB\Driver\Exception\LogicException || |
||
1 ignored issue
–
show
|
|||
44 | $e instanceof \MongoDB\Driver\Exception\BadMethodCallException) { |
||
1 ignored issue
–
show
|
|||
45 | return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", $e->getCode(), $e); |
||
46 | } elseif ($e instanceof \MongoDB\GridFS\Exception\FileNotFoundException || |
||
1 ignored issue
–
show
|
|||
47 | $e instanceof \MongoDB\GridFS\Exception\CorruptFileException) { |
||
1 ignored issue
–
show
|
|||
48 | return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", $e->getCode(), $e); |
||
49 | } elseif ($e instanceof \MongoDB\Driver\Exception\RuntimeException && |
||
1 ignored issue
–
show
|
|||
50 | ($e->getCode() == 11000 || 'E11000' == substr($e->getMessage(), 0, 6))) { |
||
51 | return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e); |
||
52 | } |
||
53 | return new \Caridea\Dao\Exception\Generic("Uncategorized database error", 0, $e); |
||
54 | } |
||
55 | } |
||
56 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.