@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected $isMultipart = false; |
69 | 69 | |
70 | 70 | private function closeConnection() { |
71 | - if(null !== $this->con) { |
|
71 | + if (null !== $this->con) { |
|
72 | 72 | curl_close($this->con); |
73 | 73 | } |
74 | 74 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function setIsJson($isJson = true) { |
233 | 233 | $this->isJson = $isJson; |
234 | - if($isJson) { |
|
234 | + if ($isJson) { |
|
235 | 235 | $this->setIsMultipart(false); |
236 | 236 | } |
237 | 237 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function setIsMultipart($isMultipart = true) { |
250 | 250 | $this->isMultipart = $isMultipart; |
251 | - if($isMultipart) { |
|
251 | + if ($isMultipart) { |
|
252 | 252 | $this->setIsJson(false); |
253 | 253 | } |
254 | 254 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $this->url = NULL; |
269 | 269 | $this->params = array(); |
270 | 270 | $this->headers = array(); |
271 | - Logger::log('Context service for ' . static::class . ' cleared!'); |
|
271 | + Logger::log('Context service for '.static::class.' cleared!'); |
|
272 | 272 | $this->closeConnection(); |
273 | 273 | } |
274 | 274 | |
@@ -311,17 +311,17 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | protected function applyOptions() { |
314 | - if(count($this->options)) { |
|
314 | + if (count($this->options)) { |
|
315 | 315 | curl_setopt_array($this->con, $this->options); |
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
319 | 319 | protected function applyHeaders() { |
320 | 320 | $headers = []; |
321 | - foreach($this->headers as $key => $value) { |
|
322 | - $headers[] = $key . ': ' . $value; |
|
321 | + foreach ($this->headers as $key => $value) { |
|
322 | + $headers[] = $key.': '.$value; |
|
323 | 323 | } |
324 | - if(count($headers)) { |
|
324 | + if (count($headers)) { |
|
325 | 325 | curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers); |
326 | 326 | } |
327 | 327 | } |
@@ -332,18 +332,18 @@ discard block |
||
332 | 332 | case Request::VERB_GET: |
333 | 333 | default: |
334 | 334 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_GET); |
335 | - if(!empty($this->params)) { |
|
335 | + if (!empty($this->params)) { |
|
336 | 336 | $sep = !preg_match('/\?/', $this->getUrl()) ? '?' : ''; |
337 | - $this->url = $this->url . $sep . http_build_query($this->params); |
|
337 | + $this->url = $this->url.$sep.http_build_query($this->params); |
|
338 | 338 | } |
339 | 339 | break; |
340 | 340 | case Request::VERB_POST: |
341 | 341 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_POST); |
342 | - if($this->getIsJson()) { |
|
342 | + if ($this->getIsJson()) { |
|
343 | 343 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
344 | - } elseif($this->getIsMultipart()) { |
|
344 | + } elseif ($this->getIsMultipart()) { |
|
345 | 345 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
346 | - } else { |
|
346 | + }else { |
|
347 | 347 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
348 | 348 | } |
349 | 349 | break; |
@@ -353,21 +353,21 @@ discard block |
||
353 | 353 | case Request::VERB_PUT: |
354 | 354 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_PUT); |
355 | 355 | |
356 | - if($this->getIsJson()) { |
|
356 | + if ($this->getIsJson()) { |
|
357 | 357 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
358 | - } elseif($this->getIsMultipart()) { |
|
358 | + } elseif ($this->getIsMultipart()) { |
|
359 | 359 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
360 | - } else { |
|
360 | + }else { |
|
361 | 361 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
362 | 362 | } |
363 | 363 | break; |
364 | 364 | case Request::VERB_PATCH: |
365 | 365 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_PATCH); |
366 | - if($this->getIsJson()) { |
|
366 | + if ($this->getIsJson()) { |
|
367 | 367 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
368 | - } elseif($this->getIsMultipart()) { |
|
368 | + } elseif ($this->getIsMultipart()) { |
|
369 | 369 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
370 | - } else { |
|
370 | + }else { |
|
371 | 371 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
372 | 372 | } |
373 | 373 | break; |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | $this->setDefaults(); |
385 | 385 | $this->applyOptions(); |
386 | 386 | $this->applyHeaders(); |
387 | - if('debug' === Config::getParam('log.level')) { |
|
387 | + if ('debug' === Config::getParam('log.level')) { |
|
388 | 388 | curl_setopt($this->con, CURLOPT_VERBOSE, true); |
389 | 389 | $verbose = fopen('php://temp', 'w+'); |
390 | 390 | curl_setopt($this->con, CURLOPT_STDERR, $verbose); |
391 | 391 | } |
392 | 392 | $result = curl_exec($this->con); |
393 | 393 | $this->result = $this->isJson ? json_decode($result, true) : $result; |
394 | - if('debug' === Config::getParam('log.level')) { |
|
394 | + if ('debug' === Config::getParam('log.level')) { |
|
395 | 395 | rewind($verbose); |
396 | 396 | $verboseLog = stream_get_contents($verbose); |
397 | 397 | Logger::log($verboseLog, LOG_DEBUG, [ |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | ]); |
402 | 402 | $this->info['verbose'] = $verboseLog; |
403 | 403 | } |
404 | - Logger::log($this->url . ' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
404 | + Logger::log($this->url.' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
405 | 405 | $this->info = array_merge($this->info, curl_getinfo($this->con)); |
406 | 406 | } |
407 | 407 |