| Conditions | 4 |
| Paths | 4 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 10 | private function checkPathExists(array $path, array $array): bool |
|
| 28 | { |
||
| 29 | // As soon as a step is not found, the path does not exist |
||
| 30 | 10 | $step = array_shift($path); |
|
| 31 | 10 | if (! array_key_exists($step, $array)) { |
|
| 32 | 5 | return false; |
|
| 33 | } |
||
| 34 | |||
| 35 | // Once the path is empty, we have found all the parts in the path |
||
| 36 | 7 | if (empty($path)) { |
|
| 37 | 5 | return true; |
|
| 38 | } |
||
| 39 | |||
| 40 | // If current value is not an array, then we have not found the path |
||
| 41 | 5 | $newArray = $array[$step]; |
|
| 42 | 5 | if (! is_array($newArray)) { |
|
| 43 | 1 | return false; |
|
| 44 | } |
||
| 45 | |||
| 46 | 5 | return $this->checkPathExists($path, $newArray); |
|
| 47 | } |
||
| 48 | |||
| 68 |