src/Browser.php
public function withBase($baseUri)
    {
        $browser = clone $this;
        $browser->baseUri = $this->messageFactory->uri($baseUri);

        if ($browser->baseUri->getScheme() === '' || $browser->baseUri->getHost() === '') {
            throw new \InvalidArgumentException('Base URI must be absolute');
        }

        return $browser;
    }
public function withBase($baseUri)
    {
        $browser = clone $this;
        $browser->baseUri = $this->messageFactory->uri($baseUri);

        if ($browser->baseUri->getScheme() === '' || $browser->baseUri->getHost() === '') {
            throw new \InvalidArgumentException('Base URI must be absolute');
        }

        return $browser;
    }
public function withBase ( $ baseUri ) { $ browser = clone $ this ; $ browser -> baseUri = $ this -> messageFactory -> uri ( $ baseUri ) ; if ( $ browser -> baseUri -> getScheme ( ) === '' || $ browser -> baseUri -> getHost ( ) === '' ) { throw new \ InvalidArgumentException ( 'Base URI must be absolute' ) ; } return $ browser ; }
Changes the base URI used to resolve relative URIs to.

```php
$newBrowser = $browser->withBase('http://api.example.com/v3');
```

Notice that the [`Browser`](#browser) is an immutable object, i.e. the `withBase()` method
actually returns a *new* [`Browser`](#browser) instance with the given base URI applied.

Any requests to relative URIs will then be processed by first prepending
the (absolute) base URI.
Please note that this merely prepends the base URI and does *not* resolve
any relative path references (like `../` etc.).
This is mostly useful for (RESTful) API calls where all endpoints (URIs)
are located under a common base URI scheme.

```php
// will request http://api.example.com/v3/example
$newBrowser->get('/example')->then(…);
```

By definition of this library, a given base URI MUST always absolute and
can not contain any placeholders.

@param string|UriInterface $baseUri absolute base URI
@return self
@throws InvalidArgumentException if the given $baseUri is not a valid absolute URI
@see self::withoutBase()
Changes the base URI used to resolve relative URIs to .