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);
    }