Conditions | 6 |
Paths | 10 |
Total Lines | 27 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
25 | protected function getNode($entity, int $claim = 0): ?Node |
||
26 | { |
||
27 | if (is_null($entity)) { |
||
28 | return null; |
||
29 | } |
||
30 | |||
31 | if ($entity instanceof ReferenceInterface) { |
||
32 | return new Node(Node::PROMISED, $entity->__scope(), $entity->__role()); |
||
33 | } |
||
34 | |||
35 | $node = $this->orm->getHeap()->get($entity); |
||
36 | |||
37 | if (is_null($node)) { |
||
38 | // possibly rely on relation target role, it will allow context switch |
||
39 | $node = new Node(Node::NEW, [], $this->orm->getMapper($entity)->getRole()); |
||
40 | $this->orm->getHeap()->attach($entity, $node); |
||
41 | } |
||
42 | |||
43 | if ($claim === 1) { |
||
44 | $node->getState()->addClaim(); |
||
45 | } |
||
46 | |||
47 | if ($claim === -1) { |
||
48 | $node->getState()->decClaim(); |
||
49 | } |
||
50 | |||
51 | return $node; |
||
52 | } |
||
53 | } |