private static function myValidateParts(int $port, UrlPathInterface $urlPath, ?string $queryString, ?string $fragment, ?string &$error): bool
    {
        // Validate port.
        if (!self::myValidatePort($port, $error)) {
            return false;
        }

        // Url path can not be relative.
        if ($urlPath->isRelative()) {
            $error = 'Url path "' . $urlPath . '" is relative.';

            return false;
        }

        // Validate query string.
        if (!self::myValidateQueryString($queryString, $error)) {
            return false;
        }

        // Validate fragment.
        if (!self::myValidateFragment($fragment, $error)) {
            return false;
        }

        return true;
    }