Conditions | 5 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 65 | protected function getEntry(array $path, ?ARecord $parentNode = null): ?ARecord |
|
28 | { |
||
29 | 65 | if (empty($path)) { |
|
30 | // no root node |
||
31 | 15 | return null; |
|
32 | } |
||
33 | |||
34 | 61 | foreach ($path as $levelKey) { |
|
35 | 61 | $search = new Search($this->getLookupRecord()); |
|
36 | 43 | $search->exact($this->getTranslation()->getCurrentKey(), strval($levelKey)); |
|
37 | 43 | if ($parentNode) { |
|
38 | 18 | $search->exact( |
|
39 | 18 | $this->getTranslation()->getParentKey(), |
|
40 | 18 | strval($parentNode->__get($this->getTranslation()->getPrimaryKey())) |
|
41 | ); |
||
42 | } |
||
43 | 43 | $all = $search->getResults(); |
|
44 | 43 | if (empty($all)) { |
|
45 | 27 | return null; |
|
46 | } |
||
47 | |||
48 | 33 | $parentNode = reset($all); |
|
49 | } |
||
50 | |||
51 | 31 | return $parentNode; |
|
52 | } |
||
56 |