| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 52 | protected function request(string $urlPath, array $data, string $contentType = 'json') |
||
| 53 | { |
||
| 54 | $options = [ |
||
| 55 | 'protocols' => ['https'], |
||
| 56 | 'connect_timeout' => 15, |
||
| 57 | 'headers' => [ |
||
| 58 | 'Content-Type' => 'application/' . $contentType . '; charset=UTF8', |
||
| 59 | 'X-Accept' => 'application/json', |
||
| 60 | ], |
||
| 61 | ]; |
||
| 62 | |||
| 63 | switch ($contentType) { |
||
| 64 | case 'json': |
||
| 65 | $options = $options + ['body' => json_encode($data)]; |
||
| 66 | break; |
||
| 67 | case 'x-www-form-urlencoded': |
||
| 68 | $options = $options + ['form_params' => $data]; |
||
| 69 | break; |
||
| 70 | } |
||
| 71 | |||
| 72 | $response = $this->pocket->getHttpClient()->post($urlPath, $options); |
||
| 73 | |||
| 74 | return $response; |
||
| 75 | } |
||
| 76 | } |
||
| 77 |