Conditions | 5 |
Paths | 7 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
41 | public function get() |
||
42 | { |
||
43 | $parent = $this->child->getParent(); |
||
44 | |||
45 | if ($parent) { |
||
46 | return $parent; |
||
47 | } |
||
48 | |||
49 | $parentClass = $this->parentClass; |
||
50 | |||
51 | $parentId = $this->child->getParentId(); |
||
52 | |||
53 | $innerHits = $this->child->getInnerHits(); |
||
54 | |||
55 | if ($innerHits) { |
||
56 | $attributes = $innerHits->getParent($parentClass::getType()); |
||
57 | $parent = new $parentClass($attributes); |
||
58 | } elseif ($parentId) { |
||
59 | $parent = $parentClass::find($parentId); |
||
60 | } |
||
61 | |||
62 | if ($parent) { |
||
63 | $this->child->setParent($parent); |
||
64 | } |
||
65 | |||
66 | return $parent; |
||
67 | } |
||
68 | |||
86 |