| @@ 42-57 (lines=16) @@ | ||
| 39 | * @throws \InvalidArgumentException |
|
| 40 | * @throws \RuntimeException |
|
| 41 | */ |
|
| 42 | public function __construct($options = array()) |
|
| 43 | { |
|
| 44 | if (!function_exists('curl_init') || !is_callable('curl_init')) |
|
| 45 | { |
|
| 46 | throw new \RuntimeException('Cannot use a cURL transport when curl_init() is not available.'); |
|
| 47 | } |
|
| 48 | ||
| 49 | if (!is_array($options) && !($options instanceof \ArrayAccess)) |
|
| 50 | { |
|
| 51 | throw new \InvalidArgumentException( |
|
| 52 | 'The options param must be an array or implement the ArrayAccess interface.' |
|
| 53 | ); |
|
| 54 | } |
|
| 55 | ||
| 56 | $this->options = $options; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Send a request to the server and return a Response object with the response. |
|
| @@ 41-63 (lines=23) @@ | ||
| 38 | * @since 1.0 |
|
| 39 | * @throws \RuntimeException |
|
| 40 | */ |
|
| 41 | public function __construct($options = array()) |
|
| 42 | { |
|
| 43 | // Verify that fopen() is available. |
|
| 44 | if (!self::isSupported()) |
|
| 45 | { |
|
| 46 | throw new \RuntimeException('Cannot use a stream transport when fopen() is not available.'); |
|
| 47 | } |
|
| 48 | ||
| 49 | // Verify that URLs can be used with fopen(); |
|
| 50 | if (!ini_get('allow_url_fopen')) |
|
| 51 | { |
|
| 52 | throw new \RuntimeException('Cannot use a stream transport when "allow_url_fopen" is disabled.'); |
|
| 53 | } |
|
| 54 | ||
| 55 | if (!is_array($options) && !($options instanceof \ArrayAccess)) |
|
| 56 | { |
|
| 57 | throw new \InvalidArgumentException( |
|
| 58 | 'The options param must be an array or implement the ArrayAccess interface.' |
|
| 59 | ); |
|
| 60 | } |
|
| 61 | ||
| 62 | $this->options = $options; |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Send a request to the server and return a Response object with the response. |
|