Conditions | 2 |
Paths | 2 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 2.032 |
Changes | 0 |
1 | <?php |
||
30 | 2 | public function __invoke($id) |
|
31 | { |
||
32 | 2 | if ($id instanceof ID) { |
|
33 | 2 | $type = $id->getNodeType(); |
|
34 | 2 | $searchValue = $id->getDatabaseId(); |
|
35 | } else { |
||
36 | //when use a different field to fetch, |
||
37 | //@see QueryGet::fetchBy |
||
38 | $searchValue = $id; |
||
39 | |||
40 | $type = $this->getContext()->getNodeDefinition()->getName(); |
||
41 | } |
||
42 | |||
43 | 2 | $entityClass = $this->getContext()->getEndpoint()->getClassForType($type); |
|
44 | |||
45 | 2 | return $this->getManager() |
|
46 | 2 | ->getRepository($entityClass) |
|
47 | 2 | ->findOneBy([$this->fetchBy => $searchValue]); |
|
48 | } |
||
50 |