Conditions | 6 |
Paths | 5 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 15 |
Ratio | 100 % |
Tests | 10 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
22 | 3 | View Code Duplication | public function getReferenceSoft($name) |
|
|||
23 | { |
||
24 | 3 | if (!isset($this->_manager)) { |
|
25 | 1 | throw new RepositoryException('Model is not handled by a managed repository'); |
|
26 | } |
||
27 | 2 | if (array_key_exists($name, $this->_references)) { |
|
28 | 2 | $ref = $this->_references[$name]; |
|
29 | 2 | $repo = $this->_manager->getByClass($ref['model']); |
|
30 | 2 | if (!$repo || !($repo instanceof SoftRepositoryInterface)) { |
|
31 | 1 | throw new RepositoryException('Referenced model is not handled by a managed soft-deletion-aware repository'); |
|
32 | } |
||
33 | 1 | return ($repo->findSoft($ref['key'], $this->{$ref['attribute']}) ?: null); |
|
34 | } |
||
35 | 1 | return null; |
|
36 | } |
||
37 | } |
||
38 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.