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