private function buildRouteUri(RouteContract $route, array $variables = [], array $query = []): UriInterface
    {
        $uri = $this->uri
            ->withScheme($route->scheme() ?: $this->request->getUri()->getScheme())
            ->withHost($route->host() ?: $this->request->getUri()->getHost())
            ->withPath($route->compilePath($variables));

        if ($query) {
            $uri = $uri->withQuery(http_build_query($query));
        }

        return $this->addPortToUri($uri);
    }