Conditions | 4 |
Paths | 10 |
Total Lines | 27 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
35 | public function sendData($data) |
||
36 | { |
||
37 | $query = ['version' => $data['version']]; |
||
38 | |||
39 | if (isset($data['verbose'])) { |
||
40 | $query['verbose'] = $data['verbose']; |
||
41 | } |
||
42 | |||
43 | $request = new Request( |
||
44 | 'GET', |
||
45 | $this->getApiUrl(static::CLASSIFIERS_PATH) . '?' . http_build_query($query), |
||
46 | ['Authorization' => 'Basic ' . base64_encode($data['username'] . ':' . $data['password'])] |
||
47 | ); |
||
48 | |||
49 | $this->response = null; |
||
50 | |||
51 | try { |
||
52 | $response = $this->httpClient->send($request); |
||
53 | $this->response = new ClassifiersResponse($this, $response->getBody()); |
||
54 | } catch (ClientException $e) { |
||
55 | if ($e->getCode() == 401) { |
||
56 | throw new AuthException('Invalid credentials provided'); |
||
57 | } |
||
58 | } |
||
59 | |||
60 | return $this->response; |
||
61 | } |
||
62 | } |
||
63 |