src/Viserio/Component/Routing/Generator/UrlGenerator.php
protected function toRoute(RouteContract $route, array $parameters, int $referenceType): string
    {
        $path = $this->prepareRoutePath($route, $parameters);
        $uri  = $this->uriFactory->createUri('/' . \ltrim($path, '/'));

        if (($host = $route->getDomain()) !== null) {
            $uri = $uri->withHost($host);
        } else {
            $uri = $uri->withHost($this->request->getUri()->getHost());
        }

        $requiredSchemes = $this->isSchemeRequired($route);

        if ($referenceType === self::ABSOLUTE_URL || $requiredSchemes || $referenceType === self::NETWORK_PATH) {
            $uri = $this->addPortAndSchemeToUri($uri, $route);
        }

        if ($referenceType === self::ABSOLUTE_URL || $requiredSchemes) {
            return (string) $uri;
        }

        if ($referenceType === self::NETWORK_PATH) {
            $uri = $uri->withScheme('');

            return (string) $uri;
        }

        return '/' . self::getRelativePath('//' . $uri->getHost() . '/', (string) $uri);
    }
protected function toRoute(RouteContract $route, array $parameters, int $referenceType): string
    {
        $path = $this->prepareRoutePath($route, $parameters);
        $uri  = $this->uriFactory->createUri('/' . \ltrim($path, '/'));

        if (($host = $route->getDomain()) !== null) {
            $uri = $uri->withHost($host);
        } else {
            $uri = $uri->withHost($this->request->getUri()->getHost());
        }

        $requiredSchemes = $this->isSchemeRequired($route);

        if ($referenceType === self::ABSOLUTE_URL || $requiredSchemes || $referenceType === self::NETWORK_PATH) {
            $uri = $this->addPortAndSchemeToUri($uri, $route);
        }

        if ($referenceType === self::ABSOLUTE_URL || $requiredSchemes) {
            return (string) $uri;
        }

        if ($referenceType === self::NETWORK_PATH) {
            $uri = $uri->withScheme('');

            return (string) $uri;
        }

        return '/' . self::getRelativePath('//' . $uri->getHost() . '/', (string) $uri);
    }
Get the URL for a given route instance.

@param \Viserio\Component\Contract\Routing\Route $route
@param array                                     $parameters
@param int                                       $referenceType

@return string