QueryPath\CSS\QueryPathEventHandler::attrValMatches PHP Метод

attrValMatches() защищенный Метод

Check for attr value matches based on an operation.
protected attrValMatches ( $needle, $haystack, $operation )
    protected function attrValMatches($needle, $haystack, $operation)
    {
        if (strlen($haystack) < strlen($needle)) {
            return false;
        }
        // According to the spec:
        // "The case-sensitivity of attribute names in selectors depends on the document language."
        // (6.3.2)
        // To which I say, "huh?". We assume case sensitivity.
        switch ($operation) {
            case EventHandler::isExactly:
                return $needle == $haystack;
            case EventHandler::containsWithSpace:
                return in_array($needle, explode(' ', $haystack));
            case EventHandler::containsWithHyphen:
                return in_array($needle, explode('-', $haystack));
            case EventHandler::containsInString:
                return strpos($haystack, $needle) !== false;
            case EventHandler::beginsWith:
                return strpos($haystack, $needle) === 0;
            case EventHandler::endsWith:
                //return strrpos($haystack, $needle) === strlen($needle) - 1;
                return preg_match('/' . $needle . '$/', $haystack) == 1;
        }
        return false;
        // Shouldn't be able to get here.
    }