| Conditions | 6 |
| Paths | 7 |
| Total Lines | 35 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 6.0045 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | 64 | protected function getEntry(array $path, ?ARecord $parentNode = null): ?ARecord |
|
| 28 | { |
||
| 29 | 64 | if (empty($path)) { |
|
| 30 | 18 | $search = new Search($this->getLookupRecord()); |
|
| 31 | 17 | $search->null($this->getTranslation()->getParentKey()); |
|
| 32 | 17 | $all = $search->getResults(); |
|
| 33 | |||
| 34 | 17 | if (empty($all)) { |
|
| 35 | // no root node?!?! |
||
| 36 | // @codeCoverageIgnoreStart |
||
| 37 | return null; |
||
| 38 | } |
||
| 39 | // @codeCoverageIgnoreEnd |
||
| 40 | |||
| 41 | 17 | return reset($all); |
|
| 42 | } |
||
| 43 | |||
| 44 | 61 | foreach ($path as $levelKey) { |
|
| 45 | 61 | $search = new Search($this->getLookupRecord()); |
|
| 46 | 43 | $search->exact($this->getTranslation()->getCurrentKey(), strval($levelKey)); |
|
| 47 | 43 | if ($parentNode) { |
|
| 48 | 20 | $search->exact( |
|
| 49 | 20 | $this->getTranslation()->getParentKey(), |
|
| 50 | 20 | strval($parentNode->__get($this->getTranslation()->getPrimaryKey())) |
|
| 51 | ); |
||
| 52 | } |
||
| 53 | 43 | $all = $search->getResults(); |
|
| 54 | 43 | if (empty($all)) { |
|
| 55 | 27 | return null; |
|
| 56 | } |
||
| 57 | |||
| 58 | 33 | $parentNode = reset($all); |
|
| 59 | } |
||
| 60 | |||
| 61 | 31 | return $parentNode; |
|
| 62 | } |
||
| 66 |