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