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