Conditions | 4 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
95 | 3 | public function get($path) |
|
96 | { |
||
97 | 3 | $response = $this->client->get($this->api_prefix.$path)->send(); |
|
98 | 3 | if ($response->isError()) { |
|
99 | 1 | throw new \RuntimeException('Failed to query the server '.$this->client->getBaseUrl()); |
|
100 | } |
||
101 | |||
102 | 2 | $body = json_decode($response->getBody(true), true); |
|
103 | |||
104 | 2 | if (json_last_error() !== JSON_ERROR_NONE || !is_array($body)) { |
|
105 | 1 | throw new \RuntimeException('Invalid response from the server '.$this->client->getBaseUrl()); |
|
106 | } |
||
107 | |||
108 | 1 | return $body; |
|
109 | } |
||
110 | } |
||
111 |