@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | 'timeout_ms' => 'CURLOPT_TIMEOUT_MS', // milliseconds, libcurl version > 7.36.0 , |
36 | 36 | ); |
37 | 37 | public $curlHandle; |
38 | - protected $options = array( |
|
39 | - 'CURLOPT_MAXREDIRS' => 10, |
|
38 | + protected $options = array( |
|
39 | + 'CURLOPT_MAXREDIRS' => 10, |
|
40 | 40 | // 'CURLOPT_IPRESOLVE' => CURL_IPRESOLVE_V4,//IPv4 |
41 | - 'header' => true, |
|
42 | - 'method' => self::GET, |
|
43 | - 'transfer' => true, |
|
44 | - 'follow_location' => true, |
|
45 | - 'timeout' => 0); |
|
46 | - protected $endCallback; |
|
41 | + 'header' => true, |
|
42 | + 'method' => self::GET, |
|
43 | + 'transfer' => true, |
|
44 | + 'follow_location' => true, |
|
45 | + 'timeout' => 0); |
|
46 | + protected $endCallback; |
|
47 | 47 | protected $withURIQuery; |
48 | 48 | |
49 | 49 | protected function __construct() { |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | self::filterAndRaw($this->options); |
224 | - var_dump($this->options); |
|
224 | + var_dump($this->options); |
|
225 | 225 | |
226 | - curl_setopt_array($this->curlHandle, $this->options); |
|
226 | + curl_setopt_array($this->curlHandle, $this->options); |
|
227 | 227 | // curl_setopt($this->curlHandle, CURLOPT_VERBOSE, true); |
228 | 228 | |
229 | 229 | return $this; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | class Request extends Http { |
18 | 18 | protected static $curlAlias = array( |
19 | 19 | 'url' => 'CURLOPT_URL', |
20 | - 'debug' => 'CURLOPT_VERBOSE',//for debug verbose |
|
20 | + 'debug' => 'CURLOPT_VERBOSE', //for debug verbose |
|
21 | 21 | 'method' => 'CURLOPT_CUSTOMREQUEST', |
22 | 22 | 'data' => 'CURLOPT_POSTFIELDS', // array or string , file begin with '@' |
23 | 23 | 'ua' => 'CURLOPT_USERAGENT', |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | if (null === ($rawField = constant($alias))) {throw new InvalidArgumentException('field is invalid'); |
86 | 86 | } |
87 | 87 | |
88 | - return isset($this->options[$rawField])?$this->options[$rawField]:false; |
|
88 | + return isset($this->options[$rawField]) ? $this->options[$rawField] : false; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | public function hasInitialized() { |
92 | - return $this->curlHandle?true:false; |
|
92 | + return $this->curlHandle ? true : false; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | public function addQuery($data) { |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | if (isset($this->options['data'])) { |
125 | - $this->options['data'] = is_array($this->options['data'])?http_build_query($this->options['data']):$this->options['data'];//for better compatibility |
|
125 | + $this->options['data'] = is_array($this->options['data']) ? http_build_query($this->options['data']) : $this->options['data']; //for better compatibility |
|
126 | 126 | } |
127 | 127 | if (isset($this->withURIQuery)) { |
128 | - $this->options['url'] .= strpos($this->options['url'], '?') === FALSE?'?':'&'; |
|
128 | + $this->options['url'] .= strpos($this->options['url'], '?') === FALSE ? '?' : '&'; |
|
129 | 129 | $this->options['url'] .= $this->withURIQuery; |
130 | 130 | } |
131 | 131 | if (isset($this->options['callback'])) { |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | return $alias; |
255 | 255 | } |
256 | 256 | public function makeResponse($isMultiCurl = false) { |
257 | - $body = $isMultiCurl?curl_multi_getcontent($this->curlHandle):curl_exec($this->curlHandle); |
|
257 | + $body = $isMultiCurl ? curl_multi_getcontent($this->curlHandle) : curl_exec($this->curlHandle); |
|
258 | 258 | $info = curl_getinfo($this->curlHandle); |
259 | 259 | $errno = curl_errno($this->curlHandle); |
260 | 260 | $error = curl_error($this->curlHandle); |