1 | <?php |
||
19 | abstract class AbstractApi |
||
20 | { |
||
21 | /** |
||
22 | * @var \Http\Client\HttpClient |
||
23 | */ |
||
24 | protected $httpClient; |
||
25 | |||
26 | /** |
||
27 | * @var \AdamPaterson\ApiClient\Foundation\Contract\HydratorInterface |
||
28 | */ |
||
29 | protected $hydrator; |
||
30 | |||
31 | /** |
||
32 | * @var \AdamPaterson\ApiClient\Foundation\Http\RequestBuilder |
||
33 | */ |
||
34 | protected $requestBuilder; |
||
35 | |||
36 | /** |
||
37 | * AbstractApi constructor. |
||
38 | * |
||
39 | * @param \Http\Client\HttpClient $httpClient |
||
40 | * @param \AdamPaterson\ApiClient\Foundation\Contract\HydratorInterface $hydrator |
||
41 | * @param \AdamPaterson\ApiClient\Foundation\Http\RequestBuilder $requestBuilder |
||
42 | */ |
||
43 | 15 | public function __construct(HttpClient $httpClient, Hydrator $hydrator, RequestBuilder $requestBuilder) |
|
49 | |||
50 | /** |
||
51 | * @param string $path |
||
52 | * @param array $params |
||
53 | * @param array $headers |
||
54 | * |
||
55 | * @return \Psr\Http\Message\ResponseInterface |
||
56 | */ |
||
57 | 3 | protected function get(string $path, array $params = [], array $headers = []): ResponseInterface |
|
67 | |||
68 | /** |
||
69 | * @param string $path |
||
70 | * @param array $params |
||
71 | * @param array $headers |
||
72 | * |
||
73 | * @return \Psr\Http\Message\ResponseInterface |
||
74 | */ |
||
75 | 3 | protected function post(string $path, array $params = [], $headers = []): ResponseInterface |
|
79 | |||
80 | /** |
||
81 | * @param string $path |
||
82 | * @param $body |
||
83 | * @param array $headers |
||
84 | * |
||
85 | * @return \Psr\Http\Message\ResponseInterface |
||
86 | */ |
||
87 | 3 | protected function postRaw(string $path, $body, array $headers = []): ResponseInterface |
|
93 | |||
94 | /** |
||
95 | * @param string $path |
||
96 | * @param array $params |
||
97 | * @param array $headers |
||
98 | * |
||
99 | * @return \Psr\Http\Message\ResponseInterface |
||
100 | */ |
||
101 | 3 | protected function put(string $path, array $params = [], array $headers = []): ResponseInterface |
|
107 | |||
108 | /** |
||
109 | * @param string $path |
||
110 | * @param array $params |
||
111 | * @param array $headers |
||
112 | * |
||
113 | * @return \Psr\Http\Message\ResponseInterface |
||
114 | */ |
||
115 | 3 | protected function patch(string $path, array $params = [], array $headers = []): ResponseInterface |
|
121 | |||
122 | /** |
||
123 | * @param string $path |
||
124 | * @param array $params |
||
125 | * @param array $headers |
||
126 | * |
||
127 | * @return \Psr\Http\Message\ResponseInterface |
||
128 | */ |
||
129 | 3 | protected function delete(string $path, array $params = [], array $headers = []): ResponseInterface |
|
135 | |||
136 | /** |
||
137 | * @param \Psr\Http\Message\ResponseInterface $response |
||
138 | * |
||
139 | * @throws \AdamPaterson\ApiClient\Foundation\Exception\Domain\NotFoundException |
||
140 | * @throws \AdamPaterson\ApiClient\Foundation\Exception\Domain\UnknownErrorException |
||
141 | */ |
||
142 | protected function handleErrors(ResponseInterface $response) |
||
153 | |||
154 | /** |
||
155 | * @param array $params |
||
156 | * |
||
157 | * @return null|string |
||
158 | */ |
||
159 | 12 | private function createJsonBody(array $params) |
|
163 | } |
||
164 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.