@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | protected $isJson = true; |
| 60 | 60 | |
| 61 | 61 | private function closeConnection() { |
| 62 | - if(null !== $this->con) { |
|
| 62 | + if (null !== $this->con) { |
|
| 63 | 63 | curl_close($this->con); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $this->url = NULL; |
| 240 | 240 | $this->params = array(); |
| 241 | 241 | $this->headers = array(); |
| 242 | - Logger::log("Context service for " . get_called_class() . " cleared!"); |
|
| 242 | + Logger::log("Context service for ".get_called_class()." cleared!"); |
|
| 243 | 243 | $this->closeConnection(); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -282,17 +282,17 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | protected function applyOptions() { |
| 285 | - if(count($this->options)) { |
|
| 285 | + if (count($this->options)) { |
|
| 286 | 286 | curl_setopt_array($this->con, $this->options); |
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | protected function applyHeaders() { |
| 291 | 291 | $headers = []; |
| 292 | - foreach($this->headers as $key => $value) { |
|
| 293 | - $headers[] = $key . ': ' . $value; |
|
| 292 | + foreach ($this->headers as $key => $value) { |
|
| 293 | + $headers[] = $key.': '.$value; |
|
| 294 | 294 | } |
| 295 | - if(count($headers)) { |
|
| 295 | + if (count($headers)) { |
|
| 296 | 296 | curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers); |
| 297 | 297 | } |
| 298 | 298 | } |
@@ -303,16 +303,16 @@ discard block |
||
| 303 | 303 | case 'GET': |
| 304 | 304 | default: |
| 305 | 305 | $this->addOption(CURLOPT_CUSTOMREQUEST, "GET"); |
| 306 | - if(!empty($this->params)) { |
|
| 306 | + if (!empty($this->params)) { |
|
| 307 | 307 | $sep = !preg_match('/\?/', $this->getUrl()) ? '?' : ''; |
| 308 | - $this->url = $this->url . $sep . http_build_query($this->params); |
|
| 308 | + $this->url = $this->url.$sep.http_build_query($this->params); |
|
| 309 | 309 | } |
| 310 | 310 | break; |
| 311 | 311 | case 'POST': |
| 312 | 312 | $this->addOption(CURLOPT_CUSTOMREQUEST, "POST"); |
| 313 | - if($this->getIsJson()) { |
|
| 313 | + if ($this->getIsJson()) { |
|
| 314 | 314 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 315 | - } else { |
|
| 315 | + }else { |
|
| 316 | 316 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 317 | 317 | } |
| 318 | 318 | break; |
@@ -322,17 +322,17 @@ discard block |
||
| 322 | 322 | case 'PUT': |
| 323 | 323 | $this->addOption(CURLOPT_CUSTOMREQUEST, "PUT"); |
| 324 | 324 | |
| 325 | - if($this->getIsJson()) { |
|
| 325 | + if ($this->getIsJson()) { |
|
| 326 | 326 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 327 | - } else { |
|
| 327 | + }else { |
|
| 328 | 328 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 329 | 329 | } |
| 330 | 330 | break; |
| 331 | 331 | case 'PATCH': |
| 332 | 332 | $this->addOption(CURLOPT_CUSTOMREQUEST, "PATCH"); |
| 333 | - if($this->getIsJson()) { |
|
| 333 | + if ($this->getIsJson()) { |
|
| 334 | 334 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 335 | - } else { |
|
| 335 | + }else { |
|
| 336 | 336 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 337 | 337 | } |
| 338 | 338 | break; |
@@ -349,14 +349,14 @@ discard block |
||
| 349 | 349 | $this->setDefaults(); |
| 350 | 350 | $this->applyOptions(); |
| 351 | 351 | $this->applyHeaders(); |
| 352 | - if('debug' === Config::getParam('log.level')) { |
|
| 352 | + if ('debug' === Config::getParam('log.level')) { |
|
| 353 | 353 | curl_setopt($this->con, CURLOPT_VERBOSE, true); |
| 354 | 354 | $verbose = fopen('php://temp', 'w+'); |
| 355 | 355 | curl_setopt($this->con, CURLOPT_STDERR, $verbose); |
| 356 | 356 | } |
| 357 | 357 | $result = curl_exec($this->con); |
| 358 | 358 | $this->result = $this->isJson ? json_decode($result, true) : $result; |
| 359 | - if('debug' === Config::getParam('log.level')) { |
|
| 359 | + if ('debug' === Config::getParam('log.level')) { |
|
| 360 | 360 | rewind($verbose); |
| 361 | 361 | $verboseLog = stream_get_contents($verbose); |
| 362 | 362 | Logger::log($verboseLog, LOG_DEBUG, [ |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | 'url' => $this->getUrl(), |
| 366 | 366 | ]); |
| 367 | 367 | } |
| 368 | - Logger::log($this->url . ' response: ', LOG_DEBUG, $this->result); |
|
| 368 | + Logger::log($this->url.' response: ', LOG_DEBUG, $this->result); |
|
| 369 | 369 | $this->info = curl_getinfo($this->con); |
| 370 | 370 | } |
| 371 | 371 | |