private function matchRoutes(string $method, array $segments): array
    {
        $staticIds = $this->provider->getRoutesByStaticPath(implode('/', $segments));

        if ($staticIds !== []) {
            $routes = $this->getMatchingRoutes($staticIds, $method, $segments);

            if ($routes !== []) {
                return $routes;
            }
        }

        if ($segments === []) {
            return [];
        }

        $matchedIds = $this->getDynamicRouteIds($segments);
        return $this->getMatchingRoutes($matchedIds, $method, $segments);
    }