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