| Conditions | 11 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 11.968 |
| 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 | 2 | public static function translate(\Exception $e): \Exception |
|
| 38 | { |
||
| 39 | 2 | if ($e instanceof \Doctrine\ORM\EntityNotFoundException || |
|
|
1 ignored issue
–
show
|
|||
| 40 | 2 | $e instanceof \Doctrine\ORM\UnexpectedResultException || |
|
|
1 ignored issue
–
show
|
|||
| 41 | 2 | $e instanceof \Doctrine\ODM\MongoDB\DocumentNotFoundException || |
|
|
1 ignored issue
–
show
|
|||
| 42 | 2 | $e instanceof \Doctrine\ODM\CouchDB\DocumentNotFoundException) { |
|
|
1 ignored issue
–
show
|
|||
| 43 | return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", 404, $e); |
||
| 44 | 2 | } else if ($e instanceof \Doctrine\ORM\PessimisticLockException || |
|
|
1 ignored issue
–
show
|
|||
| 45 | 2 | $e instanceof \Doctrine\ORM\OptimisticLockException || |
|
|
1 ignored issue
–
show
|
|||
| 46 | 2 | $e instanceof \Doctrine\ODM\CouchDB\OptimisticLockException) { |
|
|
1 ignored issue
–
show
|
|||
| 47 | return new \Caridea\Dao\Exception\Conflicting("Optimistic or pessimistic concurrency failure", 409, $e); |
||
| 48 | 2 | } else if ($e instanceof \Doctrine\ORM\Query\QueryException || |
|
|
1 ignored issue
–
show
|
|||
| 49 | 2 | $e instanceof \Doctrine\ORM\Mapping\MappingException || |
|
|
1 ignored issue
–
show
|
|||
| 50 | 2 | $e instanceof \Doctrine\Common\Persistence\Mapping\MappingException) { |
|
|
1 ignored issue
–
show
|
|||
| 51 | return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", 0, $e); |
||
| 52 | } |
||
| 53 | 2 | 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.