Check if requested URI and method matches this route.

@param string $uri
@param string $method
@return bool
977846
public function matches($uri, $method)
    {
        // Check if request method matches.
        if (in_array($method, $this->methods)) {
            $paramValues = [];

            // Replace parameters with proper regex patterns.
            $urlRegex = preg_replace_callback(self::MATCHES_REGEX, [$this, 'regexUrl'], $this->url);

            // Check if URI matches and if it matches put results in values array.
            $pattern = '@^' . $urlRegex . '/?$@' . ($this->matchUnicode?'u':'');
            if (preg_match($pattern, $uri, $paramValues) === 1) {// There is a match.
                // Extract parameter names.
                $paramNames = [];
                preg_match_all(self::MATCHES_REGEX, $this->url, $paramNames, PREG_PATTERN_ORDER);

                // Put parameters to array to be passed to controller/function later.
                foreach ($paramNames[0] as $index => $value) {
                    $this->params[substr($value, 1)] = urldecode($paramValues[$index + 1]);
                }

                // Append passed params to executable
                $this->executable->addParams($this->params);

                // Everything is done return true.
                return true;
            }
        }
        // No match found return false.
        return false;
    }
574738
public function match($uri)
    {
        if (preg_match($this->getParsedPattern(), trim($uri), $matches) > 0) {

            $this->parameters = array_slice($matches, 1);

            return true;
        }

        return false;
    }
1209319
public function getMatch($method = null, $path = null)
    {
        $method = $method ?: $this->getRequestMethod();
        $path   = $path ?: $this->getRequestPath();

        $method = strtoupper($method);

        $methodNotAllowed = null;

        foreach ($this->routes as $pattern => $methods) {
            preg_match($this->regexifyPattern($pattern), $path, $matches);

            if ($matches) {
                $r = $this->getRouteObject($pattern, $method);

                if (!$r) {
                    // We found a match but with the wrong method
                    $methodNotAllowed = true;
                    continue;
                }

                $r->method = strtoupper($method);
                $r->args   = $this->getMatchArgs($matches);

                return $r;
            }
        }

        if ($methodNotAllowed) {
            if ($this->methodNotAllowed) {
                return (object)[
                    'before'   => [],
                    'after'    => [],
                    'args'     => [],
                    'callback' => &$this->methodNotAllowed,
                ];
            }

            throw new MethodNotAllowedException;
        }

        if ($this->notFound) {
            return (object)[
                'before'   => [],
                'after'    => [],
                'args'     => [],
                'callback' => &$this->notFound,
            ];
        }

        throw new NotFoundException;
    }
724959
public function runIfMatch($URL, $method='get'){
      return $this->match($URL,$method) ? $this->run($this->extractArgs($URL),$method) : null;
    }
1084264
public function matchRoute( string $method, string $uri )
  {
    # Make dispatcher
    $dispatcher = new \FastRoute\Dispatcher\GroupCountBased($this->routeCollector->getData());

    # Dispatch the requested METHOD and URI and see if a route matches
    $routeInfo = $dispatcher->dispatch($method, $uri);

    # Examine $RouteInfo response
    switch ($routeInfo[0])
    {
      # We found a route match
      case \FastRoute\Dispatcher::FOUND:
        # URLDecode each argument
        foreach ($routeInfo[2] as $idx=>$r)
        {
          $routeInfo[2][$idx] = \urldecode($r);
        }

        # Return the Handler + args
        return [
          'method'=>$method,
          'path'=>$uri,
          'handler'=>$routeInfo[1],
          'args'=>$routeInfo[2]
        ];
        break;

      # Nothing found
      case \FastRoute\Dispatcher::NOT_FOUND:
        return [];
        break;

      # This should never happen to us ...
      case \FastRoute\Dispatcher::METHOD_NOT_ALLOWED:
        return [];
        break;

      # Default we return empty
      default:
        return [];
        break;
    }
  }
423704
public function match($uri = null, $method = null)
    {
        $context = $this->_context;

        $uri = $uri ?: $this->getRewriteUri();

        if ($method === null) {
            $method = $this->request->getServer('REQUEST_METHOD');
        }

        $context->controller = null;
        $context->action = null;
        $context->params = [];

        $context->matched = false;

        if ($this->_prefix) {
            if (strpos($uri, $this->_prefix) === 0) {
                $handledUri = substr($uri, strlen($this->_prefix)) ?: '/';
            } else {
                $handledUri = false;
            }
        } else {
            $handledUri = $uri;
        }

        $area = null;
        $routes = $this->_simple_routes;
        if ($handledUri === false) {
            $parts = false;
        } elseif (isset($routes[$method][$handledUri])) {
            $parts = $routes[$method][$handledUri]->match($handledUri, $method);
        } elseif (isset($routes[''][$handledUri])) {
            $parts = $routes[''][$handledUri]->match($handledUri, $method);
        } else {
            $parts = false;
            $routes = $this->_regex_routes;
            for ($i = count($routes) - 1; $i >= 0; $i--) {
                $route = $routes[$i];
                if (($parts = $route->match($handledUri, $method)) !== false) {
                    if ($handledUri !== '/' && $this->_areas) {
                        if (($pos = strpos($handledUri, '/', 1)) === false) {
                            $area = Text::camelize(substr($handledUri, 1));
                        } else {
                            $area = Text::camelize(substr($handledUri, 1, $pos - 1));
                        }

                        if (!in_array($area, $this->_areas, true)) {
                            $area = null;
                        }
                    }
                    break;
                }
            }

            if ($parts === false) {
                if ($handledUri !== '/' && $this->_areas) {
                    if (($pos = strpos($handledUri, '/', 1)) !== false) {
                        $area = Text::camelize(substr($handledUri, 1, $pos - 1));
                        if (in_array($area, $this->_areas, true)) {
                            $handledUri = substr($handledUri, $pos);
                        } else {
                            $area = null;
                        }
                    } else {
                        $area = Text::camelize(substr($handledUri, 1));
                        if (in_array($area, $this->_areas, true)) {
                            $handledUri = '/';
                        } else {
                            $area = null;
                        }
                    }
                }

                $handledUri = $handledUri === '/' ? '/' : rtrim($handledUri, '/');
                $parts = $this->_default_route->match($handledUri, $method);
            }
        }

        if ($parts === false) {
            return false;
        }

        $context->matched = true;

        if ($area) {
            $context->area = $area;
        } elseif (isset($parts['area'])) {
            $context->area = $parts['area'];
        }

        $context->controller = $parts['controller'];
        $context->action = $parts['action'];
        $context->params = isset($parts['params']) ? $parts['params'] : [];

        return $context;
    }
1150296
function match(RequestInterface $request)
    {
        $method = $request->getMethod();

        if (strtoupper($method) !== strtoupper($this->getMethod()))
            return false;

        $routeMatch = clone $this;
        return $routeMatch;
    }
352716
public function match(string $path, ?string $method, ?string $host): ?RouteInterface{
        if("/" !== mb_substr($path, 0, 1)){
            $path   = "/" . $path;
        }

        $stack      = new \SplStack();

        foreach(array_reverse(explode("/", $path)) as $segment){
            $stack->push($segment);
        }

        return $this->recursionMatch($this->rootNode, $stack, $method, $host);
    }
1240540
public function match()
	{
		$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
		$method = $this->getRequestMethod();
		$uri = $this->getCurrentUri();

		// Loop all routes
		foreach ($this->routes[$method] as $route) {
			// we have a match!
			if (preg_match_all('#^' . $route['pattern'] . '$#', $uri, $matches, PREG_OFFSET_CAPTURE)) {
				die("route matched");
			}
		}
		die("no route matched");
	}
1271332
protected function httpRequest($method, $uri, array $options = [])
    {
        if (null !== $this->proxy) {
            $options[RequestOptions::PROXY] = $this->proxy;
        }

        if (!isset($options[RequestOptions::HEADERS])) {
            $options[RequestOptions::HEADERS] = $this->getHttpHeaders();
        } else {
            $options[RequestOptions::HEADERS] = array_merge($this->getHttpHeaders(), $options[RequestOptions::HEADERS]);
        }

        if (!isset($options[RequestOptions::HTTP_ERRORS])) {
            $options[RequestOptions::HTTP_ERRORS] = false;
        }

        if (!isset($options[RequestOptions::ALLOW_REDIRECTS])) {
            $options[RequestOptions::ALLOW_REDIRECTS] = false;
        }

        if (!isset($options[RequestOptions::TIMEOUT]) && null !== $this->timeout) {
            $options[RequestOptions::TIMEOUT] = $this->timeout;
        }

        if (null !== $this->qps && null !== $this->lastRequestTime) {
            $lastInterval = floor((microtime(true) - $this->lastRequestTime) * 1000000);
            $timeout = ceil(1000000 / $this->qps);
            if ($lastInterval < $timeout) {
                usleep($timeout - $lastInterval);
            }
        }

        $response = $this->getHttpClient()->request($method, $uri, $options);
        $this->lastRequestTime = microtime(true);
        $this->history[] = [
            'method' => $method,
            'uri' => $uri,
            'time' => $this->lastRequestTime,
            'status' => $response->getStatusCode(),
        ];

        return $response;
    }
493769
public function methodEquals(string $method = null): bool
    {
        if (empty($method)) {
            return true;
        }

        return $this->method === $method;
    }
259881
private function matchRequestMethod(
        string $method = null,
        array $supported = null
    ) {
        if ($supported && !in_array($method, $supported)) {
            return false;
        }

        return true;
    }
478129
public static function verify($route, $path, $method=null)
    {
        /*
         * check method comparison, if method is specified.
         */
        $routeMethod = $method;
        if (strpos($route, ':') !== false && substr($route, 0, 1) !== '/' ) {
            list($routeMethod, $route) = explode( ':', $route, 2 );
            $routeMethod = strtolower($routeMethod);
            if ($method === '*') {
                // no matching against method!
            }
            elseif (strcmp(strtolower($method), $routeMethod)) {
                return [];
            }
        }
        $route = '/'.ltrim($route, '/');
        $path  = '/'.ltrim($path, '/');
        /*
         * now verify route against the path.
         */
        // replace {name} => (?P<name>[-_0-9a-zA-Z]+)
        $route = preg_replace_callback(
            '/{([_:*0-9a-zA-Z]+)}/',
            [self::class,'identifier'],
            $route
        );
        if(substr($route, -1) === '*') {
            $route  = substr($route, 0, -1 ) . '(.*)';
        }
        // now match the route against the path.
        if (preg_match('#^'.$route.'$#', $path, $matches)) {
            if(isset($matches['trailing'])) { // with *
                if(!$matches['trailing']) {
                    $matches['matched'] = $matches[0];
                } else {
                    $matches['matched'] = substr($path, 0, -strlen($matches['trailing']));
                }
            }
            $matches['method'] = $routeMethod;
            return $matches;
        }
        return [];
    }
1250250
protected function registerRoute($method, $uri, $action = null)
    {
        if (! is_array($action)) {
            $action = array_merge($this->attributes, $action ? ['uses' => $action] : []);
        }

        return $this->router->{$method}($uri, $this->compileAction($action));
    }
405945
public function matchRouter(
        $method,
        IUrl $url,
        array &$exceptions,
        IRoute $route = null
    ) {
        try {
            $route = $this->getRoutesMatcher()
                ->match($this->getRoutes(), $method, $url);
        } catch (FilterException $ex) {
            $exceptions[] = $ex;
        }

        if ($route === null) {
            $route = $this->matchNestedRouters(
                $method, $url, $exceptions, $route
            );
        }

        return $route;
    }
1071508
public function createRequest($method, $uri)
    {
        $uri = \is_string($uri)
            ? Uri::create($uri)
            : $uri;

        return new Request($method, $uri);
    }
1352147
public function checkUri($uris)
    {
        if (!$this->request) {
            return false;
        }

        foreach ((array)$uris as $uri) {
            if ($this->uri == $uri) {
                return true;
            }
        }

        return false;
    }