1 | <?php |
||
8 | class ApiClient |
||
9 | { |
||
10 | const RESPONSE_OK = 200; |
||
11 | const RESPONSE_OK_NO_BODY = 204; |
||
12 | |||
13 | /** |
||
14 | * @var \GuzzleHttp\Client |
||
15 | */ |
||
16 | private $client; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $uniqueId; |
||
22 | |||
23 | /** |
||
24 | * @var Interfaces\Configuration |
||
25 | */ |
||
26 | private $configuration; |
||
27 | |||
28 | /** |
||
29 | * @var \Psr\Log\LoggerInterface |
||
30 | */ |
||
31 | private $logger; |
||
32 | |||
33 | /** |
||
34 | * @param Interfaces\Configuration $configuration |
||
35 | * @param \Psr\Log\LoggerInterface $logger |
||
36 | */ |
||
37 | 9 | public function __construct( |
|
46 | |||
47 | /** |
||
48 | * @param $client |
||
49 | * @return ApiClient |
||
50 | */ |
||
51 | 5 | public function setClient($client) |
|
56 | |||
57 | /** |
||
58 | * @return string |
||
59 | */ |
||
60 | 9 | public function getUniqueId() |
|
68 | |||
69 | /** |
||
70 | * @param string $uniqueId |
||
71 | * @return ApiClient |
||
72 | */ |
||
73 | 5 | public function setUniqueId($uniqueId) |
|
78 | |||
79 | /** |
||
80 | * @return \GuzzleHttp\Client |
||
81 | */ |
||
82 | 7 | public function getClient() |
|
108 | |||
109 | /** |
||
110 | * @param Interfaces\Context $context |
||
111 | * @return void |
||
112 | */ |
||
113 | 4 | public function execute(Interfaces\Context $context) |
|
168 | |||
169 | /** |
||
170 | * @param string $url |
||
171 | * @param array $options |
||
172 | * @param string $method |
||
173 | * @return void |
||
174 | */ |
||
175 | 4 | private function logRequest($url, $options, $method = '') |
|
191 | |||
192 | /** |
||
193 | * @param \Psr\Http\Message\ResponseInterface $response |
||
194 | * @return void |
||
195 | */ |
||
196 | 3 | private function logResponse( |
|
208 | |||
209 | /** |
||
210 | * @param \Psr\Http\Message\ResponseInterface $response |
||
211 | * @return bool |
||
212 | */ |
||
213 | 3 | private function checkResponse( |
|
226 | |||
227 | /** |
||
228 | * Gets the value of configuration |
||
229 | * |
||
230 | * @return Interfaces\Configuration |
||
231 | */ |
||
232 | 6 | public function getConfiguration() |
|
236 | |||
237 | /** |
||
238 | * Sets the value of Configuration |
||
239 | * |
||
240 | * @param Interfaces\Configuration $configuration |
||
241 | * @return ApiClient |
||
242 | */ |
||
243 | 9 | public function setConfiguration(Interfaces\Configuration $configuration) |
|
248 | } |
||
249 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: