| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 5.3197 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | 3 | public function __invoke($node) |
|
| 32 | { |
||
| 33 | 3 | if (!$node) { |
|
| 34 | throw new NodeNotFoundException(); |
||
| 35 | } |
||
| 36 | |||
| 37 | 3 | if ($node instanceof NodeInterface) { |
|
| 38 | 3 | return $node; |
|
|
|
|||
| 39 | } |
||
| 40 | |||
| 41 | //when use a different field to fetch, |
||
| 42 | //@see QueryGet::fetchBy |
||
| 43 | $searchValue = $node; |
||
| 44 | |||
| 45 | $type = $this->getContext()->getNodeDefinition()->getName(); |
||
| 46 | |||
| 47 | $entityClass = $this->getContext()->getEndpoint()->getClassForType($type); |
||
| 48 | |||
| 49 | return $this->getManager() |
||
| 50 | ->getRepository($entityClass) |
||
| 51 | ->findOneBy([$this->fetchBy => $searchValue]); |
||
| 52 | } |
||
| 54 |