Passed
Push — master ( e34772...4b846c )
by Fran
02:55
created
src/base/Service.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
@@ -302,16 +302,16 @@  discard block
 block discarded – undo
302 302
             case 'GET':
303 303
             default:
304 304
                 $this->addOption(CURLOPT_CUSTOMREQUEST, "GET");
305
-                if(!empty($this->params)) {
305
+                if (!empty($this->params)) {
306 306
                     $sep = !preg_match('/\?/', $this->getUrl()) ? '?' : '';
307
-                    $this->setUrl($this->getUrl() . $sep . http_build_query($this->params));
307
+                    $this->setUrl($this->getUrl().$sep.http_build_query($this->params));
308 308
                 }
309 309
                 break;
310 310
             case 'POST':
311 311
                 $this->addOption(CURLOPT_CUSTOMREQUEST, "POST");
312
-                if($this->getIsJson()) {
312
+                if ($this->getIsJson()) {
313 313
                     $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params));
314
-                } else {
314
+                }else {
315 315
                     $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params));
316 316
                 }
317 317
                 break;
@@ -321,17 +321,17 @@  discard block
 block discarded – undo
321 321
             case 'PUT':
322 322
                 $this->addOption(CURLOPT_CUSTOMREQUEST, "PUT");
323 323
 
324
-                if($this->getIsJson()) {
324
+                if ($this->getIsJson()) {
325 325
                     $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params));
326
-                } else {
326
+                }else {
327 327
                     $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params));
328 328
                 }
329 329
                 break;
330 330
             case 'PATCH':
331 331
                 $this->addOption(CURLOPT_CUSTOMREQUEST, "PATCH");
332
-                if($this->getIsJson()) {
332
+                if ($this->getIsJson()) {
333 333
                     $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params));
334
-                } else {
334
+                }else {
335 335
                     $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params));
336 336
                 }
337 337
                 break;
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
         $this->setDefaults();
349 349
         $this->applyOptions();
350 350
         $this->applyHeaders();
351
-        if('debug' === Config::getParam('log.level')) {
351
+        if ('debug' === Config::getParam('log.level')) {
352 352
             curl_setopt($this->con, CURLOPT_VERBOSE, true);
353 353
             $verbose = fopen('php://temp', 'w+');
354 354
             curl_setopt($this->con, CURLOPT_STDERR, $verbose);
355 355
         }
356 356
         $result = curl_exec($this->con);
357 357
         $this->result = $this->isJson ? json_decode($result, true) : $result;
358
-        if('debug' === Config::getParam('log.level')) {
358
+        if ('debug' === Config::getParam('log.level')) {
359 359
             rewind($verbose);
360 360
             $verboseLog = stream_get_contents($verbose);
361 361
             Logger::log($verboseLog, LOG_DEBUG, [
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                 'url' => $this->getUrl(),
365 365
             ]);
366 366
         }
367
-        Logger::log($this->url . ' response: ', LOG_DEBUG, $this->result);
367
+        Logger::log($this->url.' response: ', LOG_DEBUG, $this->result);
368 368
         $this->info = curl_getinfo($this->con);
369 369
     }
370 370
 
Please login to merge, or discard this patch.