Clue\React\Buzz\Browser::withBase PHP Méthode

withBase() public méthode

This is mostly useful for using (RESTful) HTTP APIs. Any relative URI passed to any of the request methods will simply be appended behind the given $baseUri. By definition of this library, a given base URI MUST always absolute and can not contain any placeholders.
See also: self::withoutBase()
public withBase ( string | Psr\Http\Message\UriInterface $baseUri ) : self
$baseUri string | Psr\Http\Message\UriInterface absolute base URI
Résultat self
    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;
    }

Usage Example

 public function setUp()
 {
     $url = 'http://svn.apache.org/viewvc/';
     $this->loop = LoopFactory::create();
     $browser = new Browser($this->loop);
     $this->viewvc = new Client($browser->withBase($url));
 }
All Usage Examples Of Clue\React\Buzz\Browser::withBase