1 | <?php |
||
5 | class HttpClient implements HttpClientInterface |
||
6 | { |
||
7 | /** |
||
8 | * Client config. |
||
9 | * |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $config; |
||
13 | |||
14 | /** |
||
15 | * Assign dependencies. |
||
16 | * |
||
17 | * @param array $config |
||
18 | */ |
||
19 | 16 | public function __construct(array $config = []) |
|
24 | |||
25 | /** |
||
26 | * Make a POST request. |
||
27 | * |
||
28 | * @param string $path |
||
29 | * @param mixed $body |
||
30 | * @param array $headers |
||
31 | * |
||
32 | * @return Request |
||
33 | */ |
||
34 | 8 | public function post($path, $body = null, array $headers = []) |
|
38 | |||
39 | /** |
||
40 | * Send request with HTTP client. |
||
41 | * |
||
42 | * @param string $path |
||
43 | * @param mixed $body |
||
44 | * @param string $method |
||
45 | * @param array $headers |
||
46 | * |
||
47 | * @return Response |
||
48 | */ |
||
49 | 8 | protected function request($path, $body = null, $method = 'GET', array $headers = []) |
|
56 | |||
57 | /** |
||
58 | * Create request with HTTP client. |
||
59 | * |
||
60 | * @param string $method |
||
61 | * @param string $path |
||
62 | * @param mixed $body |
||
63 | * @param array $headers |
||
64 | * |
||
65 | * @return Request |
||
66 | */ |
||
67 | 8 | protected function createRequest($method, $path, $body = null, array $headers = []) |
|
77 | |||
78 | /** |
||
79 | * Send the request. |
||
80 | * |
||
81 | * @param Request $request |
||
82 | * |
||
83 | * @return Response |
||
84 | */ |
||
85 | 4 | public function send(Request $request) |
|
110 | |||
111 | /** |
||
112 | * Build uri with possible base uri. |
||
113 | * |
||
114 | * @param string $uri |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | 4 | private function buildUri($uri) |
|
126 | } |
||
127 |