src/Url.php
public static function fromParts(SchemeInterface $scheme, HostInterface $host, ?int $port = null, UrlPathInterface $urlPath = null, ?string $queryString = null, ?string $fragment = null)
    {
        // Default values.
        if ($port === null) {
            $port = $scheme->getDefaultPort();
        }

        if ($urlPath === null) {
            $urlPath = UrlPath::parse('/');
        }

        // Validate parts.
        if (!self::myValidateParts($port, $urlPath, $queryString, $fragment, $error)) {
            throw new UrlInvalidArgumentException($error);
        }

        return new self($scheme, $host, $port, $urlPath, $queryString, $fragment);
    }
public static function fromParts(SchemeInterface $scheme, HostInterface $host, ?int $port = null, UrlPathInterface $urlPath = null, ?string $queryString = null, ?string $fragment = null)
    {
        // Default values.
        if ($port === null) {
            $port = $scheme->getDefaultPort();
        }

        if ($urlPath === null) {
            $urlPath = UrlPath::parse('/');
        }

        // Validate parts.
        if (!self::myValidateParts($port, $urlPath, $queryString, $fragment, $error)) {
            throw new UrlInvalidArgumentException($error);
        }

        return new self($scheme, $host, $port, $urlPath, $queryString, $fragment);
    }
public static function fromParts ( SchemeInterface $ scheme , HostInterface $ host , ? int $ port = null , UrlPathInterface $ urlPath = null , ? string $ queryString = null , ? string $ fragment = null ) { // Default values. if ( $ port === null ) { $ port = $ scheme -> getDefaultPort ( ) ; } if ( $ urlPath === null ) { $ urlPath = UrlPath :: parse ( '/' ) ; } // Validate parts. if ( ! self :: myValidateParts ( $ port , $ urlPath , $ queryString , $ fragment , $ error ) ) { throw new UrlInvalidArgumentException ( $ error ) ; } return new self ( $ scheme , $ host , $ port , $ urlPath , $ queryString , $ fragment ) ; }
Creates a url from url parts.

@since 1.0.0

@param SchemeInterface       $scheme      The scheme.
@param HostInterface         $host        The host.
@param int|null              $port        The port or null if default port for the scheme should be used.
@param UrlPathInterface|null $urlPath     The url path or null if root path should be used.
@param string|null           $queryString The query string or null if no query string should be used.
@param string|null           $fragment    The fragment or null if no fragment should be used.

@throws UrlInvalidArgumentException If any of the parameters are invalid.

@return UrlInterface The url.
Creates a url from url parts .