Clue\React\Buzz\Message\MessageFactory::expandBase PHP Méthode

expandBase() public méthode

The given $uri parameter can be either a relative or absolute URI and as such can not contain any URI template placeholders. As such, the outcome of this method represents a valid, absolute URI which will be returned as an instance implementing UriInterface. If the given $uri is a relative URI, it will simply be appended behind $base URI. If the given $uri is an absolute URI, it will simply be verified to be *below* the given $base URI.
See also: Browser::resolve()
public expandBase ( Psr\Http\Message\UriInterface $uri, Psr\Http\Message\UriInterface $base ) : Psr\Http\Message\UriInterface
$uri Psr\Http\Message\UriInterface
$base Psr\Http\Message\UriInterface
Résultat Psr\Http\Message\UriInterface
    public function expandBase(UriInterface $uri, UriInterface $base)
    {
        if ($uri->getScheme() !== '') {
            if (strpos((string) $uri, (string) $base) !== 0) {
                throw new \UnexpectedValueException('Invalid base, "' . $uri . '" does not appear to be below "' . $base . '"');
            }
            return $uri;
        }
        $uri = (string) $uri;
        $base = (string) $base;
        if ($uri !== '' && substr($base, -1) !== '/' && substr($uri, 0, 1) !== '?') {
            $base .= '/';
        }
        if (isset($uri[0]) && $uri[0] === '/') {
            $uri = substr($uri, 1);
        }
        return $this->uri($base . $uri);
    }