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;
    }