Matches the given url against the given annotations.

@param string                        $url         The URL.
@param MatchUrlComponentAnnotation[] $annotations Given annotations.

@return boolean
767093
public function matches($url, array $annotations)
	{
		foreach ( $annotations as $annotation ) {
			if ( $this->matchComponent($annotation, $url) ) {
				return true;
			}
		}

		return false;
	}
1033322
public function isParseMethodAnnotations(array $annotations): bool
    {
        $after = isset($annotations[After::class]) || isset($annotations[AfterThrowing::class]) || isset($annotations[AfterReturning::class]);

        return isset($annotations[Before::class]) || isset($annotations[Around::class]) || $after;
    }
281768
protected static function _applyUrlFilters($url)
    {
        $request = static::getRequest(true);
        $e = null;
        foreach (static::$_urlFilters as $filter) {
            try {
                $url = $filter($url, $request);
            } catch (Exception $e) {
                // fall through
            } catch (Throwable $e) {
                // fall through
            }
            if ($e !== null) {
                if (is_array($filter)) {
                    $ref = new ReflectionMethod($filter[0], $filter[1]);
                } else {
                    $ref = new ReflectionFunction($filter);
                }
                $message = sprintf(
                    'URL filter defined in %s on line %s could not be applied. The filter failed with: %s',
                    $ref->getFileName(),
                    $ref->getStartLine(),
                    $e->getMessage()
                );
                throw new RuntimeException($message, $e->getCode(), $e);
            }
        }

        return $url;
    }
1300487
public function matches($url, array $annotations)
	{
		foreach ( $annotations as $annotation ) {
			if ( preg_match($annotation->regexp, $url) ) {
				return true;
			}
		}

		return false;
	}
194468
public boolean matches(URL url) {
        boolean matches = false;
        if(wildcardMatches(protocol, url.getProtocol()) && wildcardMatches(host, url.getHost()) && wildcardMatches(getPath(), url.getPath())) {
            matches = true;
        }
        return matches;
    }
487764
public function match($url)
    {
        foreach ($this->_parsedRoutes as $value)
        {
            if (preg_match('!^' . $value['path'] . '$!', $url, $result) == 1)
            {
                $paramsWithValues = array();

                foreach ($value['params'] as $param)
                {
                    $paramsWithValues[$param] = $result[$param];
                }

                $value['params'] = $paramsWithValues;

                return $value;
            }
        }

        return false;
    }
1302508
public static function isHttps(string $url)
    {
        $url = UrlHelper::validateUrl($url);

        $parsedUrl = parse_url($url);
        if ($parsedUrl === false) {
            throw new InvalidArgumentException("The provided url is not valid: $url");
        }

        return $parsedUrl["scheme"] === UrlHelper::HTTPS_SCHEME;
    }
513614
public function matchWhen($url = null)
    {
        if (null !== $url) {
            $this->setMatchUrl($url);
        }

        return strpos($this->getRequestedUrl(), $this->getMatchUrl()) === 0;
    }
330519
public function equals(KHttpUrlInterface $url)
    {
        $parts = array('scheme', 'host', 'port', 'path', 'query', 'fragment');

        foreach($parts as $part)
        {
            if($this->{$part} != $url->{$part}) {
                return false;
            }
        }

        return true;
    }
1218630
public function matchDirectly($url)
    {
        if (!$this->isAcceptedRequestMethod()) {
            return false;
        }

        if (rtrim($this->url, "/") === rtrim($url, "/")) {
            return true;
        }
        return false;
    }
133765
public function match($requestUrl, $requestMethod = RequestMethodInterface::METHOD_GET)
    {
        $currentDir = dirname($_SERVER['SCRIPT_NAME']);

        foreach ($this->routes->all() as $routes) {
            // compare server request method with route's allowed http methods
            if (! in_array($requestMethod, (array)$routes->getMethods(), true)) {
                continue;
            }

            if ('/' !== $currentDir) {
                $requestUrl = str_replace($currentDir, '', $requestUrl);
            }

            $route = rtrim($routes->getRegex(), '/');
            $pattern = '@^' . preg_quote($this->basePath) . $route . '/?$@i';
            if (!preg_match($pattern, $requestUrl, $matches)) {
                continue;
            }

            $params = array();

            if (preg_match_all('/:([\w-%]+)/', $routes->getUrl(), $argument_keys)) {
                // grab array with matches
                $argument_keys = $argument_keys[1];

                // check arguments number

                if(count($argument_keys) !== (count($matches) -1)) {
                    continue;
                }

                // loop trough parameter names, store matching value in $params array
                foreach ($argument_keys as $key => $name) {
                    if (isset($matches[$key+1])) {
                        $params[$name] = $matches[$key+1];
                    }
                }
            }

            $routes->setParameters($params);
            $routes->dispatch();

            return $routes;
        }

        return false;
    }
683225
public function match($patterns)
    {
        if (!is_array($patterns)) {
            $patterns = [$patterns];
        }

        $url = $this->getUrl();

        foreach ($patterns as $pattern) {
            $pattern = str_replace(['\\*', '\\?'], ['.+', '?'], preg_quote($pattern, '|'));

            if (preg_match('|^'.$pattern.'$|i', $url)) {
                return true;
            }
        }

        return false;
    }
249184
protected function _matchRelative($url) {
        $relative = $this->_relative();
        if (!$relative) {
            return true;
        }
        $components = parse_url($url);
        if (!isset($components['host'])) {
            return true;
        }
        $path = trim($components['path'], '/');
        return strpos($path, $relative) === 0;
    }
1075132
public function match(IUrl $url) {
        if ( ! $this->compareUrlToProtocols($url, $this->getProtocols()) ||
            ! $this->compareUrlToHosts($url, $this->getHosts()) ||
            ! $this->compareUrlToTLDs($url, $this->getTlds()) ||
            ! $this->compareUrlToDomains($url, $this->getDomains()) ||
            ! $this->compareUrlToSubdomains($url, $this->getSubdomains())
        ) {
            return false;
        }

        return true;
    }
1176392
public function addRule(string $url, $callable, \Imi\Server\Route\Annotation\Route $annotation = null)
    {
        if(null === $annotation)
        {
            $annotation = new \Imi\Server\Route\Annotation\Route([
                'url' => $url,
            ]);
        }
        $this->rules[$url][$this->hashKey($annotation)] = [
            'annotation'=> $annotation,
            'callable'  => $callable,
        ];
    }
1104159
public function matches(array $matchers, array $arguments): bool
    {
        $argumentCount = count($arguments);
        $index = 0;

        foreach ($matchers as $matcher) {
            if ($matcher instanceof WildcardMatcher) {
                $matchCount = 0;
                $innerMatcher = $matcher->matcher();

                while (
                    $index < $argumentCount &&
                    $innerMatcher->matches($arguments[$index])
                ) {
                    ++$matchCount;
                    ++$index;
                }

                $maximumArguments = $matcher->maximumArguments();

                $isMatch =
                    (
                        $maximumArguments < 0 ||
                        $matchCount <= $maximumArguments
                    ) &&
                    $matchCount >= $matcher->minimumArguments();

                if (!$isMatch) {
                    return false;
                }

                continue;
            }

            if (
                $index >= $argumentCount ||
                !$matcher->matches($arguments[$index])
            ) {
                return false;
            }

            ++$index;
        }

        return $index === $argumentCount;
    }
908699
protected function matchToKeys(array $matches)
    {
        $parameterNames = $this->parameterNames();

        if (count($parameterNames) == 0) {
            return array();
        }

        $parameters = array_intersect_key($matches, array_flip($parameterNames));

        return array_filter($parameters, function ($value)
        {
            return is_string($value) && (strlen($value) > 0);
        });
    }