Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3.0123 |
Changes | 0 |
1 | <?php |
||
27 | 6 | public function getEntityReference($fqcn, $property, $identifier) |
|
28 | { |
||
29 | 6 | $metadata = $this->registry->getManagerForClass($fqcn)->getClassMetadata($fqcn); |
|
30 | |||
31 | 6 | if (!$metadata->hasAssociation($property)) { |
|
32 | 4 | return $identifier; |
|
33 | } |
||
34 | |||
35 | 2 | $target = $metadata->getAssociationTargetClass($property); |
|
36 | |||
37 | 2 | $manager = $this->registry->getManagerForClass($fqcn); |
|
38 | 2 | if (!$manager instanceof EntityManagerInterface) { |
|
39 | return $manager->find($target, $identifier); |
||
40 | } |
||
41 | |||
42 | 2 | return $manager->getPartialReference($target, $identifier); |
|
43 | } |
||
44 | } |
||
45 |