@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | protected $isMultipart = false; |
| 71 | 71 | |
| 72 | 72 | private function closeConnection() { |
| 73 | - if(null !== $this->con) { |
|
| 74 | - if(is_resource($this->con)) { |
|
| 73 | + if (null !== $this->con) { |
|
| 74 | + if (is_resource($this->con)) { |
|
| 75 | 75 | @curl_close($this->con); |
| 76 | - } else { |
|
| 76 | + }else { |
|
| 77 | 77 | $this->con = null; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function setIsJson($isJson = true) { |
| 239 | 239 | $this->isJson = $isJson; |
| 240 | - if($isJson) { |
|
| 240 | + if ($isJson) { |
|
| 241 | 241 | $this->setIsMultipart(false); |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | public function setIsMultipart($isMultipart = true) { |
| 256 | 256 | $this->isMultipart = $isMultipart; |
| 257 | - if($isMultipart) { |
|
| 257 | + if ($isMultipart) { |
|
| 258 | 258 | $this->setIsJson(false); |
| 259 | 259 | } |
| 260 | 260 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $this->url = NULL; |
| 275 | 275 | $this->params = array(); |
| 276 | 276 | $this->headers = array(); |
| 277 | - Logger::log('Context service for ' . static::class . ' cleared!'); |
|
| 277 | + Logger::log('Context service for '.static::class.' cleared!'); |
|
| 278 | 278 | $this->closeConnection(); |
| 279 | 279 | } |
| 280 | 280 | |
@@ -317,18 +317,18 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | protected function applyOptions() { |
| 320 | - if(count($this->options)) { |
|
| 320 | + if (count($this->options)) { |
|
| 321 | 321 | curl_setopt_array($this->con, $this->options); |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | protected function applyHeaders() { |
| 326 | 326 | $headers = []; |
| 327 | - foreach($this->headers as $key => $value) { |
|
| 328 | - $headers[] = $key . ': ' . $value; |
|
| 327 | + foreach ($this->headers as $key => $value) { |
|
| 328 | + $headers[] = $key.': '.$value; |
|
| 329 | 329 | } |
| 330 | 330 | $headers[self::PSFS_TRACK_HEADER] = Logger::getUid(); |
| 331 | - if(count($headers)) { |
|
| 331 | + if (count($headers)) { |
|
| 332 | 332 | curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers); |
| 333 | 333 | } |
| 334 | 334 | } |
@@ -337,10 +337,10 @@ discard block |
||
| 337 | 337 | * @return int |
| 338 | 338 | */ |
| 339 | 339 | private function parseServiceType() { |
| 340 | - if($this->getIsJson()) { |
|
| 340 | + if ($this->getIsJson()) { |
|
| 341 | 341 | return ServiceHelper::TYPE_JSON; |
| 342 | 342 | } |
| 343 | - if($this->getIsMultipart()) { |
|
| 343 | + if ($this->getIsMultipart()) { |
|
| 344 | 344 | return ServiceHelper::TYPE_MULTIPART; |
| 345 | 345 | } |
| 346 | 346 | return ServiceHelper::TYPE_HTTP; |
@@ -353,9 +353,9 @@ discard block |
||
| 353 | 353 | case Request::VERB_GET: |
| 354 | 354 | default: |
| 355 | 355 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_GET); |
| 356 | - if(!empty($this->params)) { |
|
| 356 | + if (!empty($this->params)) { |
|
| 357 | 357 | $sep = false === strpos($this->getUrl(), '?') ? '?' : ''; |
| 358 | - $this->url = $this->url . $sep . http_build_query($this->params); |
|
| 358 | + $this->url = $this->url.$sep.http_build_query($this->params); |
|
| 359 | 359 | } |
| 360 | 360 | break; |
| 361 | 361 | case Request::VERB_POST: |
@@ -387,14 +387,14 @@ discard block |
||
| 387 | 387 | $this->applyOptions(); |
| 388 | 388 | $this->applyHeaders(); |
| 389 | 389 | $verbose = null; |
| 390 | - if('debug' === Config::getParam('log.level')) { |
|
| 390 | + if ('debug' === Config::getParam('log.level')) { |
|
| 391 | 391 | curl_setopt($this->con, CURLOPT_VERBOSE, true); |
| 392 | 392 | $verbose = fopen('php://temp', 'wb+'); |
| 393 | 393 | curl_setopt($this->con, CURLOPT_STDERR, $verbose); |
| 394 | 394 | } |
| 395 | 395 | $result = curl_exec($this->con); |
| 396 | 396 | $this->setResult($this->isJson ? json_decode($result, true) : $result); |
| 397 | - if('debug' === Config::getParam('log.level')) { |
|
| 397 | + if ('debug' === Config::getParam('log.level')) { |
|
| 398 | 398 | rewind($verbose); |
| 399 | 399 | $verboseLog = stream_get_contents($verbose); |
| 400 | 400 | Logger::log($verboseLog, LOG_DEBUG, [ |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | ]); |
| 405 | 405 | $this->info['verbose'] = $verboseLog; |
| 406 | 406 | } |
| 407 | - Logger::log($this->url . ' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
| 407 | + Logger::log($this->url.' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
| 408 | 408 | $this->info = array_merge($this->info, curl_getinfo($this->con)); |
| 409 | 409 | } |
| 410 | 410 | |