Nathanmac\Utilities\Parser\Parser::hasValueAtKey PHP Method

hasValueAtKey() private method

Array contains a value identified from the key, returns bool
private hasValueAtKey ( $key, $data ) : boolean
$key
$data
return boolean
    private function hasValueAtKey($key, $data)
    {
        $keys = explode('.', $key);
        while (count($keys) > 0) {
            $key = array_shift($keys);
            // Wildcard Key
            if (preg_match($this->wildcards, $key) && is_array($data) && !empty($data)) {
                // Shift the first item of the array
                if (preg_match('/^:(index|item)\\[\\d+\\]$/', $key)) {
                    for ($x = substr($key, 7, -1); $x >= 0; $x--) {
                        if (empty($data)) {
                            return false;
                        }
                        $item = array_shift($data);
                    }
                } elseif ($key == ':last') {
                    $item = array_pop($data);
                } else {
                    $item = array_shift($data);
                }
                $data =& $item;
            } else {
                if (!isset($data[$key])) {
                    return false;
                }
                if (is_bool($data[$key])) {
                    return true;
                }
                if ($data[$key] === '') {
                    return false;
                }
                $data =& $data[$key];
            }
        }
        return true;
    }