| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | 6 | public function fetch(Entity $self, EntityManager $entityManager) |
|
| 38 | 2 | { |
|
| 39 | $reference = $this->getOpponent()->getReference(); |
||
| 40 | 4 | if (empty($reference)) { |
|
| 41 | throw new InvalidConfiguration('Reference is not defined in opponent'); |
||
| 42 | } |
||
| 43 | 3 | $foreignKey = $this->getForeignKey($self, array_flip($reference)); |
|
| 44 | 3 | ||
| 45 | 3 | /** @var EntityFetcher $fetcher */ |
|
| 46 | $fetcher = $entityManager->fetch($this->class); |
||
| 47 | foreach ($foreignKey as $col => $value) { |
||
| 48 | 3 | $fetcher->where($col, $value); |
|
| 49 | } |
||
| 50 | |||
| 51 | return $fetcher; |
||
| 52 | 6 | } |
|
| 53 | |||
| 65 |
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.