@@ -230,7 +230,9 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | public function expects($mime) |
| 232 | 232 | { |
| 233 | - if (empty($mime)) return $this; |
|
| 233 | + if (empty($mime)) { |
|
| 234 | + return $this; |
|
| 235 | + } |
|
| 234 | 236 | $this->expected_type = Mime::getFullMime($mime); |
| 235 | 237 | return $this; |
| 236 | 238 | } |
@@ -257,7 +259,9 @@ discard block |
||
| 257 | 259 | */ |
| 258 | 260 | public function getIni($field = null) |
| 259 | 261 | { |
| 260 | - if(!$field) return $this->options; |
|
| 262 | + if(!$field) { |
|
| 263 | + return $this->options; |
|
| 264 | + } |
|
| 261 | 265 | $full = self::fullOption($field); |
| 262 | 266 | return isset($this->options[$full]) ? $this->options[$full] : false; |
| 263 | 267 | } |
@@ -437,12 +441,15 @@ discard block |
||
| 437 | 441 | public function send($isMultiCurl = false) |
| 438 | 442 | { |
| 439 | 443 | try { |
| 440 | - if (!$this->hasInitialized) |
|
| 441 | - $this->applyOptions(); |
|
| 444 | + if (!$this->hasInitialized) { |
|
| 445 | + $this->applyOptions(); |
|
| 446 | + } |
|
| 442 | 447 | $response = $this->makeResponse($isMultiCurl); |
| 443 | 448 | $response->parse(); |
| 444 | 449 | } catch (\Exception $e) { |
| 445 | - if(!isset($response)) $response = Response::create($this, null, null, null, null); |
|
| 450 | + if(!isset($response)) { |
|
| 451 | + $response = Response::create($this, null, null, null, null); |
|
| 452 | + } |
|
| 446 | 453 | $response->error = $e->getMessage(); |
| 447 | 454 | $response->errorCode = 999; |
| 448 | 455 | } |
@@ -506,12 +513,19 @@ discard block |
||
| 506 | 513 | $this->serializeBody(); |
| 507 | 514 | |
| 508 | 515 | //try fix url |
| 509 | - if (strpos($this->options['url'], '://') === FALSE) $this->options['url'] = 'http://' . $this->options['url']; |
|
| 516 | + if (strpos($this->options['url'], '://') === FALSE) { |
|
| 517 | + $this->options['url'] = 'http://' . $this->options['url']; |
|
| 518 | + } |
|
| 510 | 519 | $components = parse_url($this->options['url']); |
| 511 | - if(FALSE === $components) throw new InvalidArgumentException('formatting url occurs error: '. $this->options['url']); |
|
| 520 | + if(FALSE === $components) { |
|
| 521 | + throw new InvalidArgumentException('formatting url occurs error: '. $this->options['url']); |
|
| 522 | + } |
|
| 512 | 523 | if($this->withURIQuery){ |
| 513 | - if(isset($components['query'])) $components['query'] .= '&'. trim($this->withURIQuery); |
|
| 514 | - else $components['query'] = trim($this->withURIQuery); |
|
| 524 | + if(isset($components['query'])) { |
|
| 525 | + $components['query'] .= '&'. trim($this->withURIQuery); |
|
| 526 | + } else { |
|
| 527 | + $components['query'] = trim($this->withURIQuery); |
|
| 528 | + } |
|
| 515 | 529 | } |
| 516 | 530 | $this->options['url'] = self::combineUrl($components); |
| 517 | 531 | |
@@ -553,7 +567,10 @@ discard block |
||
| 553 | 567 | } |
| 554 | 568 | |
| 555 | 569 | $cURLOptions = self::filterAndRaw($this->options); |
| 556 | - if(isset($this->body))$cURLOptions[CURLOPT_POSTFIELDS] = $this->body;//use serialized body not raw data |
|
| 570 | + if(isset($this->body)) { |
|
| 571 | + $cURLOptions[CURLOPT_POSTFIELDS] = $this->body; |
|
| 572 | + } |
|
| 573 | + //use serialized body not raw data |
|
| 557 | 574 | curl_setopt_array($this->curlHandle, $cURLOptions); |
| 558 | 575 | |
| 559 | 576 | return $this; |
@@ -564,7 +581,9 @@ discard block |
||
| 564 | 581 | if (isset($this->options['data'])) { |
| 565 | 582 | if (isset($this->sendMime)) { |
| 566 | 583 | $method = $this->sendMime; |
| 567 | - if (!method_exists($this, $method)) throw new InvalidOperationException($method . ' is not exists in ' . __CLASS__); |
|
| 584 | + if (!method_exists($this, $method)) { |
|
| 585 | + throw new InvalidOperationException($method . ' is not exists in ' . __CLASS__); |
|
| 586 | + } |
|
| 568 | 587 | $this->body = $this->$method($this->options['data']); |
| 569 | 588 | } else { |
| 570 | 589 | $this->body = is_array($this->options['data']) ? http_build_query($this->options['data']) : $this->options['data']; |