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