HippoPHP\Hippo\Config\Config::navigateToKey PHP Method

navigateToKey() private method

private navigateToKey ( string $key, boolean $createSections ) : mixed
$key string
$createSections boolean
return mixed reference to the branch under given key
    private function &navigateToKey($key, $createSections)
    {
        $current =& $this->array;
        foreach (explode('.', $key) as $key) {
            if (!is_array($current)) {
                if ($createSections) {
                    $current = [];
                } else {
                    throw new BadConfigKeyException('Trying to access child of a scalar value: ' . $key);
                }
            }
            if (!isset($current[$this->normalizeKey($key)])) {
                if ($createSections) {
                    $current[$this->normalizeKey($key)] = [];
                } else {
                    throw new BadConfigKeyException('Trying to access a node that doesn\'t exist: ' . $key);
                }
            }
            $current =& $current[$this->normalizeKey($key)];
        }
        return $current;
    }