@@ -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 | |
@@ -281,17 +281,17 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | protected function applyOptions() { |
| 284 | - if(count($this->options)) { |
|
| 284 | + if (count($this->options)) { |
|
| 285 | 285 | curl_setopt_array($this->con, $this->options); |
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | protected function applyHeaders() { |
| 290 | 290 | $headers = []; |
| 291 | - foreach($this->headers as $key => $value) { |
|
| 292 | - $headers[] = $key . ': ' . $value; |
|
| 291 | + foreach ($this->headers as $key => $value) { |
|
| 292 | + $headers[] = $key.': '.$value; |
|
| 293 | 293 | } |
| 294 | - if(count($headers)) { |
|
| 294 | + if (count($headers)) { |
|
| 295 | 295 | curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers); |
| 296 | 296 | } |
| 297 | 297 | } |
@@ -305,9 +305,9 @@ discard block |
||
| 305 | 305 | break; |
| 306 | 306 | case 'POST': |
| 307 | 307 | $this->addOption(CURLOPT_CUSTOMREQUEST, "POST"); |
| 308 | - if($this->getIsJson()) { |
|
| 308 | + if ($this->getIsJson()) { |
|
| 309 | 309 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 310 | - } else { |
|
| 310 | + }else { |
|
| 311 | 311 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 312 | 312 | } |
| 313 | 313 | break; |
@@ -317,17 +317,17 @@ discard block |
||
| 317 | 317 | case 'PUT': |
| 318 | 318 | $this->addOption(CURLOPT_CUSTOMREQUEST, "PUT"); |
| 319 | 319 | |
| 320 | - if($this->getIsJson()) { |
|
| 320 | + if ($this->getIsJson()) { |
|
| 321 | 321 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 322 | - } else { |
|
| 322 | + }else { |
|
| 323 | 323 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 324 | 324 | } |
| 325 | 325 | break; |
| 326 | 326 | case 'PATCH': |
| 327 | 327 | $this->addOption(CURLOPT_CUSTOMREQUEST, "PATCH"); |
| 328 | - if($this->getIsJson()) { |
|
| 328 | + if ($this->getIsJson()) { |
|
| 329 | 329 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 330 | - } else { |
|
| 330 | + }else { |
|
| 331 | 331 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 332 | 332 | } |
| 333 | 333 | break; |
@@ -344,14 +344,14 @@ discard block |
||
| 344 | 344 | $this->setDefaults(); |
| 345 | 345 | $this->applyOptions(); |
| 346 | 346 | $this->applyHeaders(); |
| 347 | - if('debug' === Config::getParam('log.level')) { |
|
| 347 | + if ('debug' === Config::getParam('log.level')) { |
|
| 348 | 348 | curl_setopt($this->con, CURLOPT_VERBOSE, true); |
| 349 | 349 | $verbose = fopen('php://temp', 'w+'); |
| 350 | 350 | curl_setopt($this->con, CURLOPT_STDERR, $verbose); |
| 351 | 351 | } |
| 352 | 352 | $result = curl_exec($this->con); |
| 353 | 353 | $this->result = json_decode($result, true); |
| 354 | - if('debug' === Config::getParam('log.level')) { |
|
| 354 | + if ('debug' === Config::getParam('log.level')) { |
|
| 355 | 355 | rewind($verbose); |
| 356 | 356 | $verboseLog = stream_get_contents($verbose); |
| 357 | 357 | Logger::log($verboseLog, LOG_DEBUG, [ |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | 'url' => $this->getUrl(), |
| 361 | 361 | ]); |
| 362 | 362 | } |
| 363 | - Logger::log($this->url . ' response: ', LOG_DEBUG, $this->result); |
|
| 363 | + Logger::log($this->url.' response: ', LOG_DEBUG, $this->result); |
|
| 364 | 364 | $this->info = curl_getinfo($this->con); |
| 365 | 365 | } |
| 366 | 366 | |