Serializer
5 years ago
Curl.php
5 years ago
Encoder.php
4 years ago
Environment.php
5 years ago
HttpClient.php
4 years ago
HttpException.php
4 years ago
HttpRequest.php
5 years ago
HttpResponse.php
4 years ago
IOException.php
5 years ago
Injector.php
4 years ago
Serializer.php
5 years ago
Curl.php
58 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PayPalHttp; |
| 4 | |
| 5 | /** |
| 6 | * Class Curl |
| 7 | * @package PayPalHttp |
| 8 | * |
| 9 | * Curl wrapper used by HttpClient to make curl requests. |
| 10 | * @see HttpClient |
| 11 | */ |
| 12 | class Curl |
| 13 | { |
| 14 | protected $curl; |
| 15 | |
| 16 | public function __construct($curl = NULL) |
| 17 | { |
| 18 | |
| 19 | if (is_null($curl)) |
| 20 | { |
| 21 | $curl = curl_init(); |
| 22 | } |
| 23 | $this->curl = $curl; |
| 24 | } |
| 25 | |
| 26 | public function setOpt($option, $value) |
| 27 | { |
| 28 | curl_setopt($this->curl, $option, $value); |
| 29 | return $this; |
| 30 | } |
| 31 | |
| 32 | public function close() |
| 33 | { |
| 34 | curl_close($this->curl); |
| 35 | return $this; |
| 36 | } |
| 37 | |
| 38 | public function exec() |
| 39 | { |
| 40 | return curl_exec($this->curl); |
| 41 | } |
| 42 | |
| 43 | public function errNo() |
| 44 | { |
| 45 | return curl_errno($this->curl); |
| 46 | } |
| 47 | |
| 48 | public function getInfo($option) |
| 49 | { |
| 50 | return curl_getinfo($this->curl, $option); |
| 51 | } |
| 52 | |
| 53 | public function error() |
| 54 | { |
| 55 | return curl_error($this->curl); |
| 56 | } |
| 57 | } |
| 58 |