for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace VDB\Spider\RequestHandler;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Message\Request;
use GuzzleHttp\Message\RequestInterface;
use VDB\Spider\RequestHandler\RequestHandlerInterface;
use VDB\Spider\Resource;
use VDB\Spider\Uri\DiscoveredUri;
/**
* @author Matthijs van den Bos <[email protected]>
* @copyright 2013 Matthijs van den Bos
*/
class GuzzleRequestHandler implements RequestHandlerInterface
{
/** @var Client */
private $client;
/** @var HandlerStack */
private $handlerStack;
* @param HandlerStack $handlerStack
* @return RequestHandlerInterface
public function setHandlerStack(HandlerStack $handlerStack)
$this->handlerStack = $handlerStack;
return $this;
}
* @return HandlerStack
public function getHandlerStack()
if (!$this->handlerStack) {
$this->handlerStack = HandlerStack::create();
return $this->handlerStack;
* @param Client $client
public function setClient(Client $client)
$this->client = $client;
* @return Client
public function getClient()
if (!$this->client) {
$this->client = new Client(['config' => $this->getHandlerStack()]);
return $this->client;
* @param DiscoveredUri $uri
* @return Resource
public function request(DiscoveredUri $uri)
$response = $this->getClient()->get($uri->toString());
return new Resource($uri, $response);