@@ -54,10 +54,11 @@ |
||
| 54 | 54 | $headers = explode(PHP_EOL, $headers); |
| 55 | 55 | array_shift($headers); // HTTP HEADER |
| 56 | 56 | foreach($headers as $h) { |
| 57 | - if(false !== strpos($h, ':')) |
|
| 58 | - list($k, $v) = explode(':', $h, 2); |
|
| 59 | - else |
|
| 60 | - list($k, $v) = array($h,''); |
|
| 57 | + if(false !== strpos($h, ':')) { |
|
| 58 | + list($k, $v) = explode(':', $h, 2); |
|
| 59 | + } else { |
|
| 60 | + list($k, $v) = array($h,''); |
|
| 61 | + } |
|
| 61 | 62 | |
| 62 | 63 | $this->header[trim($k)] = trim($v); |
| 63 | 64 | } |
@@ -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'; |
@@ -17,8 +17,11 @@ |
||
| 17 | 17 | public static function retry($maxTimes = 2, callable $task, $sleep = 0){ |
| 18 | 18 | $tryTimes = 0; |
| 19 | 19 | while(++$tryTimes <= $maxTimes){ |
| 20 | - if($task()) break; |
|
| 21 | - else usleep(abs($sleep) * 1000000); |
|
| 20 | + if($task()) { |
|
| 21 | + break; |
|
| 22 | + } else { |
|
| 23 | + usleep(abs($sleep) * 1000000); |
|
| 24 | + } |
|
| 22 | 25 | } |
| 23 | 26 | return $tryTimes; |
| 24 | 27 | } |
@@ -121,7 +121,4 @@ |
||
| 121 | 121 | curl_multi_close(self::$multiHandler); |
| 122 | 122 | self::$requestPool = array(); |
| 123 | 123 | self::$multiHandler = null; |
| 124 | - return $return; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | -} |
|
| 124 | + return $return |
|
| 128 | 125 | \ No newline at end of file |
@@ -121,7 +121,4 @@ |
||
| 121 | 121 | curl_multi_close(self::$multiHandler); |
| 122 | 122 | self::$requestPool = array(); |
| 123 | 123 | self::$multiHandler = null; |
| 124 | - return $return; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | -} |
|
| 124 | + return $return |
|
| 128 | 125 | \ No newline at end of file |
@@ -683,9 +683,4 @@ |
||
| 683 | 683 | { |
| 684 | 684 | if ($response->hasErrors()) { |
| 685 | 685 | self::$logger->error($response->request->getURI() . "\t" . $response->error, array( |
| 686 | - 'response' => print_r($response, 1), |
|
| 687 | - )); |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - } |
|
| 691 | -} |
|
| 686 | + 'response' => print_r($response |
|
| 692 | 687 | \ No newline at end of file |
@@ -683,9 +683,4 @@ |
||
| 683 | 683 | { |
| 684 | 684 | if ($response->hasErrors()) { |
| 685 | 685 | self::$logger->error($response->request->getURI() . "\t" . $response->error, array( |
| 686 | - 'response' => print_r($response, 1), |
|
| 687 | - )); |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - } |
|
| 691 | -} |
|
| 686 | + 'response' => print_r($response |
|
| 692 | 687 | \ No newline at end of file |