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