Conditions | 3 |
Paths | 5 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | public function sendData($data) |
||
25 | { |
||
26 | $request = new Request( |
||
27 | 'GET', |
||
28 | $this->getApiUrl(static::CLASSIFIERS_PATH) . '?' . http_build_query(['version' => $data['version']]), |
||
29 | ['Authorization' => 'Basic ' . base64_encode($data['username'] . ':' . $data['password'])] |
||
30 | ); |
||
31 | |||
32 | $this->response = null; |
||
33 | |||
34 | try { |
||
35 | $response = $this->httpClient->send($request); |
||
36 | $this->response = new ClassifiersResponse($this, $response->getBody()); |
||
37 | } catch (ClientException $e) { |
||
38 | if ($e->getCode() == 401) { |
||
39 | throw new AuthException('Invalid credentials provided'); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | return $this->response; |
||
44 | } |
||
45 | } |
||
46 |