if (null ===
$baseUri) { throw new \
InvalidArgumentException('The URI is relative, so you must define its base URI passing an absolute URL.'
);
} // empty URI
if (!
$uri) { return $baseUri;
} // an anchor
if ('#' ===
$uri[0
]) { return self::
cleanupAnchor($baseUri).
$uri;
} $baseUriCleaned = self::
cleanupUri($baseUri);
if ('?' ===
$uri[0
]) { return $baseUriCleaned.
$uri;
} // absolute URL with relative schema
if (str_starts_with($uri, '//'
)) { return preg_replace('#^([^/]*)//.*$#', '$1',
$baseUriCleaned).
$uri;
}