private function getMatchingRoutes(array $ids, string $method, array $segments): array
    {
        $routes = [];

        foreach ($ids as $id) {
            $definition = $this->provider->getRouteDefinition($id);
            $values = [];

            if (!$definition->matchPatterns($segments, $values)) {
                continue;
            }

            if (!$definition->isMethodAllowed($method)) {
                array_push($this->allowedMethods, ... $definition->getMethods());
                continue;
            }

            $routes[] = new Route($definition, $method, $segments, $values);
        }

        return $routes;
    }