| @@ -13,24 +13,24 @@ | ||
| 13 | 13 | |
| 14 | 14 |  trait RequestTrait { | 
| 15 | 15 | protected $expectContentType = null; | 
| 16 | -    public function expectsJson(){ | |
| 16 | +    public function expectsJson() { | |
| 17 | 17 | $this->expectContentType = Mime::JSON; | 
| 18 | 18 | } | 
| 19 | -    public function expectsXml(){ | |
| 19 | +    public function expectsXml() { | |
| 20 | 20 | $this->expectContentType = Mime::XML; | 
| 21 | 21 | } | 
| 22 | 22 | |
| 23 | -    protected function json(){ | |
| 23 | +    protected function json() { | |
| 24 | 24 | |
| 25 | 25 | } | 
| 26 | -    protected function unJson(){ | |
| 26 | +    protected function unJson() { | |
| 27 | 27 | |
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | -    protected function xml(){ | |
| 30 | +    protected function xml() { | |
| 31 | 31 | |
| 32 | 32 | } | 
| 33 | -    protected function unXml(){ | |
| 33 | +    protected function unXml() { | |
| 34 | 34 | |
| 35 | 35 | } | 
| 36 | 36 | } | 
| @@ -31,7 +31,7 @@ discard block | ||
| 31 | 31 | protected static $curlAlias = array( | 
| 32 | 32 | 'url' => 'CURLOPT_URL', | 
| 33 | 33 | 'uri' => 'CURLOPT_URL', | 
| 34 | - 'debug' => 'CURLOPT_VERBOSE',//for debug verbose | |
| 34 | + 'debug' => 'CURLOPT_VERBOSE', //for debug verbose | |
| 35 | 35 | 'method' => 'CURLOPT_CUSTOMREQUEST', | 
| 36 | 36 | 'data' => 'CURLOPT_POSTFIELDS', // array or string , file begin with '@' | 
| 37 | 37 | 'ua' => 'CURLOPT_USERAGENT', | 
| @@ -52,8 +52,8 @@ discard block | ||
| 52 | 52 | */ | 
| 53 | 53 | 'expectsMime' => null, //expected mime | 
| 54 | 54 | 'sendMime' => null, //send mime | 
| 55 | - 'ip' => null,//specify ip to send request | |
| 56 | - 'callback' => null,//callback on end | |
| 55 | + 'ip' => null, //specify ip to send request | |
| 56 | + 'callback' => null, //callback on end | |
| 57 | 57 | |
| 58 | 58 | ); | 
| 59 | 59 | protected static $loggerHandler; | 
| @@ -64,9 +64,9 @@ discard block | ||
| 64 | 64 | $expectedMime; | 
| 65 | 65 | protected $options = array( | 
| 66 | 66 | 'CURLOPT_MAXREDIRS' => 10, | 
| 67 | - 'CURLOPT_SSL_VERIFYPEER' => false,//for https | |
| 68 | - 'CURLOPT_SSL_VERIFYHOST' => 0,//for https | |
| 69 | - 'CURLOPT_IPRESOLVE' => CURL_IPRESOLVE_V4,//ipv4 first | |
| 67 | + 'CURLOPT_SSL_VERIFYPEER' => false, //for https | |
| 68 | + 'CURLOPT_SSL_VERIFYHOST' => 0, //for https | |
| 69 | + 'CURLOPT_IPRESOLVE' => CURL_IPRESOLVE_V4, //ipv4 first | |
| 70 | 70 | 'header' => true, | 
| 71 | 71 | 'method' => self::GET, | 
| 72 | 72 | 'transfer' => true, | 
| @@ -106,15 +106,15 @@ discard block | ||
| 106 | 106 | */ | 
| 107 | 107 | private static function combineUrl($parsedComponents) | 
| 108 | 108 |      { | 
| 109 | - $scheme = isset($parsedComponents['scheme']) ? $parsedComponents['scheme'] . '://' : ''; | |
| 109 | + $scheme = isset($parsedComponents['scheme']) ? $parsedComponents['scheme'].'://' : ''; | |
| 110 | 110 | $host = isset($parsedComponents['host']) ? $parsedComponents['host'] : ''; | 
| 111 | - $port = isset($parsedComponents['port']) ? ':' . $parsedComponents['port'] : ''; | |
| 111 | + $port = isset($parsedComponents['port']) ? ':'.$parsedComponents['port'] : ''; | |
| 112 | 112 | $user = isset($parsedComponents['user']) ? $parsedComponents['user'] : ''; | 
| 113 | - $pass = isset($parsedComponents['pass']) ? ':' . $parsedComponents['pass'] : ''; | |
| 113 | + $pass = isset($parsedComponents['pass']) ? ':'.$parsedComponents['pass'] : ''; | |
| 114 | 114 | $pass = ($user || $pass) ? "$pass@" : ''; | 
| 115 | 115 | $path = isset($parsedComponents['path']) ? $parsedComponents['path'] : ''; | 
| 116 | - $query = isset($parsedComponents['query']) ? '?' . $parsedComponents['query'] : ''; | |
| 117 | - $fragment = isset($parsedComponents['fragment']) ? '#' . $parsedComponents['fragment'] : ''; | |
| 116 | + $query = isset($parsedComponents['query']) ? '?'.$parsedComponents['query'] : ''; | |
| 117 | + $fragment = isset($parsedComponents['fragment']) ? '#'.$parsedComponents['fragment'] : ''; | |
| 118 | 118 | return "$scheme$user$pass$host$port$path$query$fragment"; | 
| 119 | 119 | } | 
| 120 | 120 | |
| @@ -146,7 +146,7 @@ discard block | ||
| 146 | 146 | */ | 
| 147 | 147 | public function addHeader($headerName, $value) | 
| 148 | 148 |      { | 
| 149 | - $this->options['headers'][] = $headerName . ': ' . $value; | |
| 149 | + $this->options['headers'][] = $headerName.': '.$value; | |
| 150 | 150 | return $this; | 
| 151 | 151 | } | 
| 152 | 152 | |
| @@ -204,7 +204,7 @@ discard block | ||
| 204 | 204 | */ | 
| 205 | 205 | public function getIni($field = null) | 
| 206 | 206 |      { | 
| 207 | - if(!$field) return $this->options; | |
| 207 | + if (!$field) return $this->options; | |
| 208 | 208 | $full = self::fullOption($field); | 
| 209 | 209 | return isset($this->options[$full]) ? $this->options[$full] : false; | 
| 210 | 210 | } | 
| @@ -262,7 +262,7 @@ discard block | ||
| 262 | 262 | */ | 
| 263 | 263 | protected function ini($method, $url, $data, array $options = array()) | 
| 264 | 264 |      { | 
| 265 | -        $options = array('url' => $url, 'method' => $method, 'data' => $data) + $options; | |
| 265 | +        $options = array('url' => $url, 'method' => $method, 'data' => $data)+$options; | |
| 266 | 266 | $this->addOptions($options); | 
| 267 | 267 | |
| 268 | 268 | return $this; | 
| @@ -274,7 +274,7 @@ discard block | ||
| 274 | 274 | */ | 
| 275 | 275 | public function addOptions(array $options = array()) | 
| 276 | 276 |      { | 
| 277 | - $this->options = $options + $this->options; | |
| 277 | + $this->options = $options+$this->options; | |
| 278 | 278 | $this->uri = $this->options['url']; | 
| 279 | 279 | return $this; | 
| 280 | 280 | } | 
| @@ -363,7 +363,7 @@ discard block | ||
| 363 | 363 | $response = $this->makeResponse($isMultiCurl); | 
| 364 | 364 | $response->parse(); | 
| 365 | 365 |          } catch (\Exception $e) { | 
| 366 | - if(!isset($response)) $response = Response::create($this, null, null, null, null); | |
| 366 | + if (!isset($response)) $response = Response::create($this, null, null, null, null); | |
| 367 | 367 | $response->error = $e->getMessage(); | 
| 368 | 368 | $response->errorCode = 999; | 
| 369 | 369 | } | 
| @@ -400,12 +400,12 @@ discard block | ||
| 400 | 400 |              throw new InvalidArgumentException('url can not empty'); | 
| 401 | 401 | } | 
| 402 | 402 | |
| 403 | -        if(isset($this->options['expectsMime'])){ | |
| 403 | +        if (isset($this->options['expectsMime'])) { | |
| 404 | 404 | $this->expectsMime($this->options['expectsMime']); | 
| 405 | 405 | // unset($this->options['expectsMime']); | 
| 406 | 406 | } | 
| 407 | 407 | |
| 408 | -        if(isset($this->options['sendMime'])){ | |
| 408 | +        if (isset($this->options['sendMime'])) { | |
| 409 | 409 | $this->sendMime($this->options['sendMime']); | 
| 410 | 410 | // unset($this->options['sendMime']); | 
| 411 | 411 | } | 
| @@ -413,11 +413,11 @@ discard block | ||
| 413 | 413 | $this->serializeBody(); | 
| 414 | 414 | |
| 415 | 415 | //try fix url | 
| 416 | - if (strpos($this->options['url'], '://') === FALSE) $this->options['url'] = 'http://' . $this->options['url']; | |
| 416 | + if (strpos($this->options['url'], '://') === FALSE) $this->options['url'] = 'http://'.$this->options['url']; | |
| 417 | 417 | $components = parse_url($this->options['url']); | 
| 418 | -        if(FALSE === $components) throw new InvalidArgumentException('formatting url occurs error: '. $this->options['url']); | |
| 419 | -        if($this->withURIQuery){ | |
| 420 | - if(isset($components['query'])) $components['query'] .= '&'. trim($this->withURIQuery); | |
| 418 | +        if (FALSE === $components) throw new InvalidArgumentException('formatting url occurs error: '.$this->options['url']); | |
| 419 | +        if ($this->withURIQuery) { | |
| 420 | + if (isset($components['query'])) $components['query'] .= '&'.trim($this->withURIQuery); | |
| 421 | 421 | else $components['query'] = trim($this->withURIQuery); | 
| 422 | 422 | } | 
| 423 | 423 | $this->options['url'] = self::combineUrl($components); | 
| @@ -432,11 +432,11 @@ discard block | ||
| 432 | 432 |              preg_match('/\/\/([^\/]+)/', $this->options['url'], $matches); | 
| 433 | 433 | $host = $matches[1]; | 
| 434 | 434 |              if (empty($this->options['headers']) || !is_array($this->options['headers'])) { | 
| 435 | -                $this->options['headers'] = array('Host: ' . $host); | |
| 435 | +                $this->options['headers'] = array('Host: '.$host); | |
| 436 | 436 |              } else { | 
| 437 | - $this->options['headers'][] = 'Host: ' . $host; | |
| 437 | + $this->options['headers'][] = 'Host: '.$host; | |
| 438 | 438 | } | 
| 439 | -            $this->options['url'] = preg_replace('/\/\/([^\/]+)/', '//' . $this->options['ip'], $this->options['url']); | |
| 439 | +            $this->options['url'] = preg_replace('/\/\/([^\/]+)/', '//'.$this->options['ip'], $this->options['url']); | |
| 440 | 440 | // unset($this->options['ip']); | 
| 441 | 441 | unset($host); | 
| 442 | 442 | } | 
| @@ -455,7 +455,7 @@ discard block | ||
| 455 | 455 | //convert secs to milliseconds | 
| 456 | 456 |          if (defined('CURLOPT_TIMEOUT_MS')) { | 
| 457 | 457 |              if (!isset($this->options['timeout_ms'])) { | 
| 458 | - $this->options['timeout_ms'] = intval($this->options['timeout'] * 1000); | |
| 458 | + $this->options['timeout_ms'] = intval($this->options['timeout']*1000); | |
| 459 | 459 |              } else { | 
| 460 | 460 | $this->options['timeout_ms'] = intval($this->options['timeout_ms']); | 
| 461 | 461 | } | 
| @@ -473,10 +473,10 @@ discard block | ||
| 473 | 473 |          if (isset($this->options['data'])) { | 
| 474 | 474 |              if (isset($this->sendMime)) { | 
| 475 | 475 | $method = $this->sendMime; | 
| 476 | - if (!method_exists($this, $method)) throw new InvalidOperationException($method . ' is not exists in ' . __CLASS__); | |
| 476 | + if (!method_exists($this, $method)) throw new InvalidOperationException($method.' is not exists in '.__CLASS__); | |
| 477 | 477 | $this->options['data'] = $this->$method($this->options['data']); | 
| 478 | 478 |              } else { | 
| 479 | - $this->options['data'] = is_array($this->options['data']) ? http_build_query($this->options['data']) : $this->options['data'];//for better compatibility | |
| 479 | + $this->options['data'] = is_array($this->options['data']) ? http_build_query($this->options['data']) : $this->options['data']; //for better compatibility | |
| 480 | 480 | } | 
| 481 | 481 | } | 
| 482 | 482 | } | 
| @@ -488,7 +488,7 @@ discard block | ||
| 488 | 488 | public function onEnd(callable $callback) | 
| 489 | 489 |      { | 
| 490 | 490 |          if (!is_callable($callback)) { | 
| 491 | -            throw new InvalidArgumentException('callback not is callable :' . print_r($callback, 1)); | |
| 491 | +            throw new InvalidArgumentException('callback not is callable :'.print_r($callback, 1)); | |
| 492 | 492 | } | 
| 493 | 493 | |
| 494 | 494 | $this->endCallback = $callback; | 
| @@ -204,7 +204,9 @@ discard block | ||
| 204 | 204 | */ | 
| 205 | 205 | public function getIni($field = null) | 
| 206 | 206 |      { | 
| 207 | - if(!$field) return $this->options; | |
| 207 | +        if(!$field) { | |
| 208 | + return $this->options; | |
| 209 | + } | |
| 208 | 210 | $full = self::fullOption($field); | 
| 209 | 211 | return isset($this->options[$full]) ? $this->options[$full] : false; | 
| 210 | 212 | } | 
| @@ -358,12 +360,15 @@ discard block | ||
| 358 | 360 | public function send($isMultiCurl = false) | 
| 359 | 361 |      { | 
| 360 | 362 |          try { | 
| 361 | - if (!$this->hasInitialized) | |
| 362 | - $this->applyOptions(); | |
| 363 | +            if (!$this->hasInitialized) { | |
| 364 | + $this->applyOptions(); | |
| 365 | + } | |
| 363 | 366 | $response = $this->makeResponse($isMultiCurl); | 
| 364 | 367 | $response->parse(); | 
| 365 | 368 |          } catch (\Exception $e) { | 
| 366 | - if(!isset($response)) $response = Response::create($this, null, null, null, null); | |
| 369 | +            if(!isset($response)) { | |
| 370 | + $response = Response::create($this, null, null, null, null); | |
| 371 | + } | |
| 367 | 372 | $response->error = $e->getMessage(); | 
| 368 | 373 | $response->errorCode = 999; | 
| 369 | 374 | } | 
| @@ -413,12 +418,19 @@ discard block | ||
| 413 | 418 | $this->serializeBody(); | 
| 414 | 419 | |
| 415 | 420 | //try fix url | 
| 416 | - if (strpos($this->options['url'], '://') === FALSE) $this->options['url'] = 'http://' . $this->options['url']; | |
| 421 | +        if (strpos($this->options['url'], '://') === FALSE) { | |
| 422 | + $this->options['url'] = 'http://' . $this->options['url']; | |
| 423 | + } | |
| 417 | 424 | $components = parse_url($this->options['url']); | 
| 418 | -        if(FALSE === $components) throw new InvalidArgumentException('formatting url occurs error: '. $this->options['url']); | |
| 425 | +        if(FALSE === $components) { | |
| 426 | +        	throw new InvalidArgumentException('formatting url occurs error: '. $this->options['url']); | |
| 427 | + } | |
| 419 | 428 |          if($this->withURIQuery){ | 
| 420 | - if(isset($components['query'])) $components['query'] .= '&'. trim($this->withURIQuery); | |
| 421 | - else $components['query'] = trim($this->withURIQuery); | |
| 429 | +            if(isset($components['query'])) { | |
| 430 | + $components['query'] .= '&'. trim($this->withURIQuery); | |
| 431 | +            } else { | |
| 432 | + $components['query'] = trim($this->withURIQuery); | |
| 433 | + } | |
| 422 | 434 | } | 
| 423 | 435 | $this->options['url'] = self::combineUrl($components); | 
| 424 | 436 | |
| @@ -473,7 +485,9 @@ discard block | ||
| 473 | 485 |          if (isset($this->options['data'])) { | 
| 474 | 486 |              if (isset($this->sendMime)) { | 
| 475 | 487 | $method = $this->sendMime; | 
| 476 | - if (!method_exists($this, $method)) throw new InvalidOperationException($method . ' is not exists in ' . __CLASS__); | |
| 488 | +                if (!method_exists($this, $method)) { | |
| 489 | + throw new InvalidOperationException($method . ' is not exists in ' . __CLASS__); | |
| 490 | + } | |
| 477 | 491 | $this->options['data'] = $this->$method($this->options['data']); | 
| 478 | 492 |              } else { | 
| 479 | 493 | $this->options['data'] = is_array($this->options['data']) ? http_build_query($this->options['data']) : $this->options['data'];//for better compatibility | 
| @@ -51,15 +51,15 @@ | ||
| 51 | 51 | public function unJson($body) | 
| 52 | 52 |      { | 
| 53 | 53 | $parsed = json_decode($body, true); | 
| 54 | -        if(json_last_error() !== JSON_ERROR_NONE)throw new UnexpectedResponseException('parsing json occurs error: '.  self::jsonLastErrorMsg() . ', raw body: ' .$body  ); | |
| 54 | +        if (json_last_error() !== JSON_ERROR_NONE)throw new UnexpectedResponseException('parsing json occurs error: '.self::jsonLastErrorMsg().', raw body: '.$body); | |
| 55 | 55 | return $parsed; | 
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | /** | 
| 59 | 59 | * @return string | 
| 60 | 60 | */ | 
| 61 | -    private static function jsonLastErrorMsg(){ | |
| 62 | -        if(function_exists('json_last_error_msg')) return json_last_error_msg(); | |
| 61 | +    private static function jsonLastErrorMsg() { | |
| 62 | +        if (function_exists('json_last_error_msg')) return json_last_error_msg(); | |
| 63 | 63 |          switch (json_last_error()) { | 
| 64 | 64 | case JSON_ERROR_NONE: | 
| 65 | 65 | return ' - No errors'; | 
| @@ -51,7 +51,9 @@ discard block | ||
| 51 | 51 | public function unJson($body) | 
| 52 | 52 |      { | 
| 53 | 53 | $parsed = json_decode($body, true); | 
| 54 | -        if(json_last_error() !== JSON_ERROR_NONE)throw new UnexpectedResponseException('parsing json occurs error: '.  self::jsonLastErrorMsg() . ', raw body: ' .$body  ); | |
| 54 | +        if(json_last_error() !== JSON_ERROR_NONE) { | |
| 55 | +        	throw new UnexpectedResponseException('parsing json occurs error: '.  self::jsonLastErrorMsg() . ', raw body: ' .$body  ); | |
| 56 | + } | |
| 55 | 57 | return $parsed; | 
| 56 | 58 | } | 
| 57 | 59 | |
| @@ -59,7 +61,9 @@ discard block | ||
| 59 | 61 | * @return string | 
| 60 | 62 | */ | 
| 61 | 63 |      private static function jsonLastErrorMsg(){ | 
| 62 | -        if(function_exists('json_last_error_msg')) return json_last_error_msg(); | |
| 64 | +        if(function_exists('json_last_error_msg')) { | |
| 65 | + return json_last_error_msg(); | |
| 66 | + } | |
| 63 | 67 |          switch (json_last_error()) { | 
| 64 | 68 | case JSON_ERROR_NONE: | 
| 65 | 69 | return ' - No errors'; | 
| @@ -96,9 +96,9 @@ | ||
| 96 | 96 | public function unserializeBody() | 
| 97 | 97 |      { | 
| 98 | 98 |          if (isset($this->request->expectedMime)) { | 
| 99 | -            if (Mime::getFullMime($this->request->expectedMime) !== $this->contentType) throw new UnexpectedResponseException('expected mime can not be matched, real mime:'. $this->contentType. ', expected mime:'. Mime::getFullMime($this->request->expectedMime)); | |
| 99 | +            if (Mime::getFullMime($this->request->expectedMime) !== $this->contentType) throw new UnexpectedResponseException('expected mime can not be matched, real mime:'.$this->contentType.', expected mime:'.Mime::getFullMime($this->request->expectedMime)); | |
| 100 | 100 | $method = 'un'.ucfirst($this->request->expectedMime); | 
| 101 | - if (!method_exists($this->request, $method)) throw new InvalidOperationException($method . ' is not exists in ' . __CLASS__); | |
| 101 | + if (!method_exists($this->request, $method)) throw new InvalidOperationException($method.' is not exists in '.__CLASS__); | |
| 102 | 102 |              $this->body = $this->request->{$method}($this->body); | 
| 103 | 103 | } | 
| 104 | 104 | } | 
| @@ -72,10 +72,11 @@ discard block | ||
| 72 | 72 | $headers = explode(PHP_EOL, $headers); | 
| 73 | 73 | array_shift($headers); // HTTP HEADER | 
| 74 | 74 |          foreach ($headers as $h) { | 
| 75 | - if (false !== strpos($h, ':')) | |
| 76 | -                list($k, $v) = explode(':', $h, 2); | |
| 77 | - else | |
| 78 | - list($k, $v) = array($h, ''); | |
| 75 | +            if (false !== strpos($h, ':')) { | |
| 76 | +                            list($k, $v) = explode(':', $h, 2); | |
| 77 | +            } else { | |
| 78 | + list($k, $v) = array($h, ''); | |
| 79 | + } | |
| 79 | 80 | |
| 80 | 81 | $this->header[trim($k)] = trim($v); | 
| 81 | 82 | } | 
| @@ -96,9 +97,13 @@ discard block | ||
| 96 | 97 | public function unserializeBody() | 
| 97 | 98 |      { | 
| 98 | 99 |          if (isset($this->request->expectedMime)) { | 
| 99 | -            if (Mime::getFullMime($this->request->expectedMime) !== $this->contentType) throw new UnexpectedResponseException('expected mime can not be matched, real mime:'. $this->contentType. ', expected mime:'. Mime::getFullMime($this->request->expectedMime)); | |
| 100 | +            if (Mime::getFullMime($this->request->expectedMime) !== $this->contentType) { | |
| 101 | +            	throw new UnexpectedResponseException('expected mime can not be matched, real mime:'. $this->contentType. ', expected mime:'. Mime::getFullMime($this->request->expectedMime)); | |
| 102 | + } | |
| 100 | 103 | $method = 'un'.ucfirst($this->request->expectedMime); | 
| 101 | - if (!method_exists($this->request, $method)) throw new InvalidOperationException($method . ' is not exists in ' . __CLASS__); | |
| 104 | +            if (!method_exists($this->request, $method)) { | |
| 105 | + throw new InvalidOperationException($method . ' is not exists in ' . __CLASS__); | |
| 106 | + } | |
| 102 | 107 |              $this->body = $this->request->{$method}($this->body); | 
| 103 | 108 | } | 
| 104 | 109 | } | 
| @@ -46,7 +46,7 @@ discard block | ||
| 46 | 46 | * @param array $options | 
| 47 | 47 | * @return $this | 
| 48 | 48 | */ | 
| 49 | -    public function setDefaults(array $options = array()){ | |
| 49 | +    public function setDefaults(array $options = array()) { | |
| 50 | 50 | $this->defaultOptions = $options; | 
| 51 | 51 | return $this; | 
| 52 | 52 | } | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 | 'method' => $method, | 
| 69 | 69 | 'url' => $uri, | 
| 70 | 70 | 'data' => $payload, | 
| 71 | - ) + $options; | |
| 71 | + )+$options; | |
| 72 | 72 | $this->addOptions(array($options)); | 
| 73 | 73 | return $this; | 
| 74 | 74 | } | 
| @@ -81,7 +81,7 @@ discard block | ||
| 81 | 81 | public function addOptions(array $URLOptions) | 
| 82 | 82 |      { | 
| 83 | 83 |          foreach ($URLOptions as $options) { | 
| 84 | - $options = $options + $this->defaultOptions; | |
| 84 | + $options = $options+$this->defaultOptions; | |
| 85 | 85 | $request = Request::create()->addOptions($options)->applyOptions(); | 
| 86 | 86 |              if (isset($options['callback'])) { | 
| 87 | 87 | $request->onEnd($options['callback']); | 
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 | */ | 
| 111 | 111 | public function sendAll() | 
| 112 | 112 |      { | 
| 113 | - $sleepTime = 1000;//microsecond, prevent CPU 100% | |
| 113 | + $sleepTime = 1000; //microsecond, prevent CPU 100% | |
| 114 | 114 |          do { | 
| 115 | 115 | curl_multi_exec(self::$multiHandler, $active); | 
| 116 | 116 | // bug in PHP 5.3.18+ where curl_multi_select can return -1 | 
| @@ -119,7 +119,7 @@ discard block | ||
| 119 | 119 | usleep($sleepTime); | 
| 120 | 120 | } | 
| 121 | 121 | usleep($sleepTime); | 
| 122 | - } while ($active); | |
| 122 | + }while ($active); | |
| 123 | 123 | $return = array(); | 
| 124 | 124 |          foreach (self::$requestPool as $request) { | 
| 125 | 125 | $return[] = $request->send(true); |