1 | <?php |
||
20 | class Guzzle5HttpAdapter implements HttpClient |
||
21 | { |
||
22 | /** |
||
23 | * @var ClientInterface |
||
24 | */ |
||
25 | private $client; |
||
26 | |||
27 | /** |
||
28 | * @var MessageFactory |
||
29 | */ |
||
30 | private $messageFactory; |
||
31 | |||
32 | /** |
||
33 | * @param ClientInterface|null $client |
||
34 | * @param MessageFactory|null $messageFactory |
||
35 | */ |
||
36 | public function __construct(ClientInterface $client = null, MessageFactory $messageFactory = null) |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function sendRequest(RequestInterface $request) |
||
57 | |||
58 | /** |
||
59 | * Converts a PSR request into a Guzzle request. |
||
60 | * |
||
61 | * @param RequestInterface $request |
||
62 | * |
||
63 | * @return GuzzleRequest |
||
64 | */ |
||
65 | private function createRequest(RequestInterface $request) |
||
82 | |||
83 | /** |
||
84 | * Converts a Guzzle response into a PSR response. |
||
85 | * |
||
86 | * @param GuzzleResponse $response |
||
87 | * |
||
88 | * @return ResponseInterface |
||
89 | */ |
||
90 | private function createResponse(GuzzleResponse $response) |
||
102 | |||
103 | /** |
||
104 | * Converts a Guzzle exception into an Httplug exception. |
||
105 | * |
||
106 | * @param GuzzleExceptions\TransferException $exception |
||
107 | * @param RequestInterface $request |
||
108 | * |
||
109 | * @return HttplugException |
||
110 | */ |
||
111 | private function handleException(GuzzleExceptions\TransferException $exception, RequestInterface $request) |
||
134 | } |
||
135 |