Find and return the request dynamic route based on the compiled data and Path.

@param string $httpMethod
@param string $path

@return Route|false If the request match an array with the action and parameters will
be returned otherwise a false will.
327693
protected function matchDynamicRoute($httpMethod, $path)
    {
        if ($routes = $this->collector->findDynamicRoutes($httpMethod, $path)) {
            // cache the parser reference
            $this->parser = $this->collector->getParser();
            // chunk routes for smaller regex groups using the Sturges' Formula
            foreach (array_chunk($routes, round(1 + 3.3 * log(count($routes))), true) as $chunk) {
                array_map([$this, "buildRoute"], $chunk);
                list($pattern, $map) = $this->buildGroup($chunk);

                if (!preg_match($pattern, $path, $matches)) {
                    continue;
                }

                /** @var Route $route */
                $route = $map[count($matches)];
                unset($matches[0]);

                $route->setParams(array_combine($route->getParams(), array_filter($matches)));

                return $route;
            }
        }

        return false;
    }
853415
public function get( $path, callable $callback ) {
        $route = new Route( 'GET', $path, $callback );
        $this->_routes[] = $route;
        return $route;
    }
1132109
protected function setHttpMethods(Route $route, array $httpMethods)
    {
        foreach ($httpMethods as $idx => $method) {
            $httpMethods[$idx] = strtoupper($method);
        }
        $route->via($httpMethods);
    }
979246
public static function parsePath($path, $httpMethod)
    {
        $elements       = [];
        $elementStrings = explode('/', $path);
        foreach ($elementStrings as $elementString) {
            if (empty($elementString)) {
                continue;
            }
            $elements[] = new static($elementString, $httpMethod);
        }

        return $elements;
    }
829175
public function get($path, array $parameters = [], $headers = [])
    {
        $response = $this->getClient()->getHttpClient()->get($path, $parameters, $headers);

        return $this->decodeResponse($response);
    }
549840
protected function httpGet(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface
    {
        if (count($parameters) > 0) {
            $path .= '?'.http_build_query($parameters);
        }

        try {
            $response = $this->httpClient->sendRequest(
                $this->requestBuilder->create('GET', $path, $requestHeaders)
            );
        } catch (Psr18\NetworkExceptionInterface $e) {
            throw HttpServerException::networkError($e);
        }

        return $response;
    }
492500
public function map($optionsOrMethod, $path, $handler)
    {
        $route = new Route();
        $route->map($optionsOrMethod, $path, $handler);
        $this->routes[] = $route;
        return $route;
    }
520994
protected function get($path, array $parameters = array(), $requestHeaders = array()) {
    if ($this->count !== NULL && !isset($parameters['count'])) {
      $parameters['count'] = $this->count;
    }
    $response = $this->client->getHttpClient()->get($path, $parameters, $requestHeaders);

    return ResponseMediator::getContent($response);
  }
365342
public function request(string $path, int $methods, $handler)
	{
		$path = $this->currentContext->getPrefixedPath(
			trim($path, "\n\r\t/ ")
		);

		return $this->route(new Route($path, $methods), $handler);
	}
764524
public function findFromPath($path, $method = null)
    {
        foreach ($this->getRoutes() as $route) {
            if ($matchedRoute = $route->matches($path, $method)) {
                return $matchedRoute;
            }
        }
        return null;
    }
412932
public function match(array $methods, $path, $action)
    {
        $methods = $this->normalizeRequestMethods($methods);

        return $this->addRoute($methods, $path, $action);
    }
972176
protected function dispatchRoute($httpMethod, $uri)
    {
        if (isset($this->staticRouteMap[$uri])) {
            return $this->dispatchStaticRoute($httpMethod, $uri);
        }

        return $this->dispatchVariableRoute($httpMethod, $uri);
    }
4158
public function getRoute($path = "", $name = "")
    {
        for ($i = 0; $i < count($this->routes); $i++)
        {
            $checkRoute = $this->routes[$i];

            if($checkRoute->getName() === $name || $checkRoute->getPath() === $path)
            {
                return $checkRoute;
            }
            else if($checkRoute->getRegex() != null)
            {
                $regex = $checkRoute->getRegex();

                if(preg_match($regex, $path))
                {
                    preg_match_all('/\/(\w+)/', '/'.ltrim($path, $checkRoute->getStaticPath()), $matches, PREG_SET_ORDER);
                    foreach($matches as $match)
                    {
                        $values[] = $match[1];
                    }
                    $checkRoute->setValues($values);

                    return $checkRoute;
                }
            }
        }

        return false;
    }
691537
public static function delete($path, $handlerMethod = null)
    {
        return self::factory($path, HttpMethods::DELETE, $handlerMethod);
    }
434780
public function routePage($path)
    {
        $url = URL::findByLocation($path);

        if ($url) {
            $page = $url->getPage();

            if (!$page || $page->isDeleted()) {
                // The url is in use but doesn't have a page.
                // The page must have been deleted.
                throw new GoneHttpException();
            }

            if (Editor::isDisabled() && !$page->isVisible()) {
                throw new NotFoundHttpException();
            }

            if (!$page->url()->matches($path)) {
                return redirect((string) $page->url(), 301);
            }

            $this->setActivePage($page);

            return;
        }

        throw new NotFoundHttpException();
    }
1272560
public function match($path, $method, $action = null)
    {
        $rule = new Rule\HttpMethodRule();
        $rule->setPath($path);
        $rule->setMethod($method);
        $rule->setAction($action);
        $this->rules[] = $rule;
        return $rule;
    }
1123747
public function execute($uri, $requestMethod)
    {
        foreach ($this->routes as $route) {
            if (true === $route->matches($uri, $requestMethod)) {
                return $route;
            }
        }
        return null;
    }