1 | <?php |
||
27 | class HttpMethodsClient implements HttpClient |
||
28 | { |
||
29 | /** |
||
30 | * @var HttpClient |
||
31 | */ |
||
32 | private $httpClient; |
||
33 | |||
34 | /** |
||
35 | * @var MessageFactory |
||
36 | */ |
||
37 | private $messageFactory; |
||
38 | |||
39 | /** |
||
40 | * @param HttpClient $httpClient The client to send requests with. |
||
41 | * @param MessageFactory $messageFactory The message factory to create requests. |
||
42 | */ |
||
43 | 9 | public function __construct(HttpClient $httpClient, MessageFactory $messageFactory) |
|
48 | |||
49 | /** |
||
50 | * Sends a GET request. |
||
51 | * |
||
52 | * @param string|UriInterface $uri |
||
53 | * @param array $headers |
||
54 | * |
||
55 | * @throws Exception |
||
56 | * |
||
57 | * @return ResponseInterface |
||
58 | */ |
||
59 | 1 | public function get($uri, array $headers = []) |
|
63 | |||
64 | /** |
||
65 | * Sends an HEAD request. |
||
66 | * |
||
67 | * @param string|UriInterface $uri |
||
68 | * @param array $headers |
||
69 | * |
||
70 | * @throws Exception |
||
71 | * |
||
72 | * @return ResponseInterface |
||
73 | */ |
||
74 | 1 | public function head($uri, array $headers = []) |
|
78 | |||
79 | /** |
||
80 | * Sends a TRACE request. |
||
81 | * |
||
82 | * @param string|UriInterface $uri |
||
83 | * @param array $headers |
||
84 | * |
||
85 | * @throws Exception |
||
86 | * |
||
87 | * @return ResponseInterface |
||
88 | */ |
||
89 | 1 | public function trace($uri, array $headers = []) |
|
93 | |||
94 | /** |
||
95 | * Sends a POST request. |
||
96 | * |
||
97 | * @param string|UriInterface $uri |
||
98 | * @param array $headers |
||
99 | * @param string|StreamInterface|null $body |
||
100 | * |
||
101 | * @throws Exception |
||
102 | * |
||
103 | * @return ResponseInterface |
||
104 | */ |
||
105 | 1 | public function post($uri, array $headers = [], $body = null) |
|
109 | |||
110 | /** |
||
111 | * Sends a PUT request. |
||
112 | * |
||
113 | * @param string|UriInterface $uri |
||
114 | * @param array $headers |
||
115 | * @param string|StreamInterface|null $body |
||
116 | * |
||
117 | * @throws Exception |
||
118 | * |
||
119 | * @return ResponseInterface |
||
120 | */ |
||
121 | 1 | public function put($uri, array $headers = [], $body = null) |
|
125 | |||
126 | /** |
||
127 | * Sends a PATCH request. |
||
128 | * |
||
129 | * @param string|UriInterface $uri |
||
130 | * @param array $headers |
||
131 | * @param string|StreamInterface|null $body |
||
132 | * |
||
133 | * @throws Exception |
||
134 | * |
||
135 | * @return ResponseInterface |
||
136 | */ |
||
137 | 1 | public function patch($uri, array $headers = [], $body = null) |
|
141 | |||
142 | /** |
||
143 | * Sends a DELETE request. |
||
144 | * |
||
145 | * @param string|UriInterface $uri |
||
146 | * @param array $headers |
||
147 | * @param string|StreamInterface|null $body |
||
148 | * |
||
149 | * @throws Exception |
||
150 | * |
||
151 | * @return ResponseInterface |
||
152 | */ |
||
153 | 1 | public function delete($uri, array $headers = [], $body = null) |
|
157 | |||
158 | /** |
||
159 | * Sends an OPTIONS request. |
||
160 | * |
||
161 | * @param string|UriInterface $uri |
||
162 | * @param array $headers |
||
163 | * @param string|StreamInterface|null $body |
||
164 | * |
||
165 | * @throws Exception |
||
166 | * |
||
167 | * @return ResponseInterface |
||
168 | */ |
||
169 | 1 | public function options($uri, array $headers = [], $body = null) |
|
173 | |||
174 | /** |
||
175 | * Sends a request with any HTTP method. |
||
176 | * |
||
177 | * @param string $method HTTP method to use. |
||
178 | * @param string|UriInterface $uri |
||
179 | * @param array $headers |
||
180 | * @param string|StreamInterface|null $body |
||
181 | * |
||
182 | * @throws Exception |
||
183 | * |
||
184 | * @return ResponseInterface |
||
185 | */ |
||
186 | public function send($method, $uri, array $headers = [], $body = null) |
||
195 | |||
196 | /** |
||
197 | * Forward to the underlying HttpClient. |
||
198 | * |
||
199 | * {@inheritdoc} |
||
200 | */ |
||
201 | 1 | public function sendRequest(RequestInterface $request) |
|
205 | } |
||
206 |