| Conditions | 7 |
| Paths | 16 |
| Total Lines | 28 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | public function makeRequest($method, $url, $params = []) |
||
| 45 | { |
||
| 46 | $options = []; |
||
| 47 | switch ($method) { |
||
| 48 | case self::GET: |
||
| 49 | $options['query'] = $params; |
||
| 50 | break; |
||
| 51 | case self::POST: |
||
| 52 | case self::DELETE: |
||
| 53 | // @codeCoverageIgnoreStart |
||
| 54 | case self::PUT: |
||
| 55 | // @codeCoverageIgnoreEnd |
||
| 56 | $options['body'] = is_array($params) ? json_encode($params) : $params; |
||
|
|
|||
| 57 | break; |
||
| 58 | default: |
||
| 59 | // @codeCoverageIgnoreStart |
||
| 60 | $method = 'GET'; |
||
| 61 | break; |
||
| 62 | // @codeCoverageIgnoreEnd |
||
| 63 | } |
||
| 64 | |||
| 65 | try { |
||
| 66 | $response = $this->client->request($method, $url, $options); |
||
| 67 | } catch (GuzzleException $e) { |
||
| 68 | $response = new Response($e->getCode(), [], $e->getMessage()); |
||
| 69 | } |
||
| 70 | |||
| 71 | return new ApiResponse($url, $options, $response); |
||
| 72 | } |
||
| 74 |