| Conditions | 4 |
| Paths | 8 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 83 | public function send($method, $uri = '', array $options = [], $returnData = false) |
||
| 84 | { |
||
| 85 | try { |
||
| 86 | $response = $this->client->request(strtoupper($method), $uri, $options); |
||
| 87 | $this->code = $response->getStatusCode(); |
||
| 88 | |||
| 89 | if ($returnData === false) { |
||
| 90 | return true; |
||
| 91 | } |
||
| 92 | |||
| 93 | return json_decode($response->getBody(), true); |
||
| 94 | } catch (ConnectException $e) { |
||
| 95 | $this->message = 'cannot connect to api!'; |
||
| 96 | |||
| 97 | return false; |
||
| 98 | } catch (ClientException $e) { |
||
| 99 | $this->code = $e->getResponse()->getStatusCode(); |
||
| 100 | $this->message = $e->getResponse()->getBody(); |
||
| 101 | |||
| 102 | return false; |
||
| 103 | } |
||
| 104 | } |
||
| 105 | } |
||
| 106 |