| Conditions | 3 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public function get(string $url): TransportResponseInterface |
||
| 26 | { |
||
| 27 | $ch = curl_init(); |
||
| 28 | |||
| 29 | curl_setopt_array($ch, [ |
||
| 30 | CURLOPT_CONNECTTIMEOUT => $this->connectionTimeout, |
||
| 31 | CURLOPT_RETURNTRANSFER => true, |
||
| 32 | CURLOPT_URL => $url, |
||
| 33 | ]); |
||
| 34 | |||
| 35 | $result = curl_exec($ch); |
||
| 36 | |||
| 37 | $chErrCode = curl_errno($ch); |
||
| 38 | $chErr = curl_error($ch); |
||
| 39 | |||
| 40 | $statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); |
||
| 41 | curl_close($ch); |
||
| 42 | |||
| 43 | if ($chErrCode || $chErr) { |
||
| 44 | throw new TransportRequestException(sprintf('Error while executing request in curl transport. Error: "%s".', $chErr)); |
||
| 45 | } |
||
| 46 | |||
| 47 | return new Response($statusCode, (string)$result); |
||
| 48 | } |
||
| 50 |