Passed
Push — master ( a04f2e...1b5a9b )
by Fran
05:36
created
src/base/types/helpers/RequestHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 
47 47
                     // TODO include this headers in Template class output method
48 48
                     header("Access-Control-Allow-Credentials: true");
49
-                    header("Access-Control-Allow-Origin: " . Request::getInstance()->getServer('HTTP_ORIGIN', '*'));
49
+                    header("Access-Control-Allow-Origin: ".Request::getInstance()->getServer('HTTP_ORIGIN', '*'));
50 50
                     header("Vary: Origin");
51 51
                     header("Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS");
52
-                    header("Access-Control-Allow-Headers: " . implode(', ', self::getCorsHeaders()));
52
+                    header("Access-Control-Allow-Headers: ".implode(', ', self::getCorsHeaders()));
53 53
                 }
54 54
                 if (Request::getInstance()->getMethod() === Request::VERB_OPTIONS) {
55 55
                     Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
                     if (self::validateIpAddress($ip))
79 79
                         return $ip;
80 80
                 }
81
-            } else {
81
+            }else {
82 82
                 if (self::validateIpAddress($_SERVER['HTTP_X_FORWARDED_FOR']))
83 83
                     return $_SERVER['HTTP_X_FORWARDED_FOR'];
84 84
             }
Please login to merge, or discard this patch.
src/base/types/helpers/RouterHelper.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public static function getClassToCall($action)
23 23
     {
24 24
         Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action);
25
-        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"];
25
+        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"];
26 26
         $class = method_exists($actionClass, "getInstance") ? $actionClass::getInstance() : new $actionClass;
27 27
         return $class;
28 28
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $expr = preg_quote($expr, '/');
109 109
         $expr = str_replace('###', '(.*)', $expr);
110 110
         $expr2 = preg_replace('/\(\.\*\)$/', '', $expr);
111
-        $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path);
111
+        $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path);
112 112
         return $matched;
113 113
     }
114 114
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public static function extractDomainInfo(\ReflectionClass $class, $domain)
121 121
     {
122
-        $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
123
-        $path = realpath($path) . DIRECTORY_SEPARATOR;
122
+        $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
123
+        $path = realpath($path).DIRECTORY_SEPARATOR;
124 124
         $tpl_path = "templates";
125 125
         $public_path = "public";
126 126
         $model_path = "models";
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
             $model_path = ucfirst($model_path);
131 131
         }
132 132
         if ($class->hasConstant("TPL")) {
133
-            $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL");
133
+            $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL");
134 134
         }
135 135
         return [
136 136
             'base' => $path,
137
-            'template' => $path . $tpl_path,
138
-            'model' => $path . $model_path,
139
-            'public' => $path . $public_path,
137
+            'template' => $path.$tpl_path,
138
+            'model' => $path.$model_path,
139
+            'public' => $path.$public_path,
140 140
         ];
141 141
     }
142 142
 
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
             foreach ($parameters as $param) {
161 161
                 if ($param->isOptional() && !is_array($param->getDefaultValue())) {
162 162
                     $params[$param->getName()] = $param->getDefaultValue();
163
-                    $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
164
-                } elseif(!$param->isOptional()) {
163
+                    $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex);
164
+                } elseif (!$param->isOptional()) {
165 165
                     $requirements[] = $param->getName();
166 166
                 }
167 167
             }
168
-        } else {
168
+        }else {
169 169
             $default = $regex;
170 170
         }
171 171
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             $default = str_replace('{__DOMAIN__}', $module, $default);
248 248
             $httpMethod = self::extractReflectionHttpMethod($docComments);
249 249
             $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments));
250
-            $route = $httpMethod . "#|#" . $regex;
250
+            $route = $httpMethod."#|#".$regex;
251 251
             $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route);
252 252
             $info = [
253 253
                 'method' => $method->getName(),
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,8 +59,10 @@
 block discarded – undo
59 59
         $_route = explode("/", $url['path']);
60 60
         $_pattern = explode("/", $pattern);
61 61
         $get = array();
62
-        if (!empty($_pattern)) foreach ($_pattern as $index => $component) {
62
+        if (!empty($_pattern)) {
63
+            foreach ($_pattern as $index => $component) {
63 64
             $_get = array();
65
+        }
64 66
             preg_match_all('/^\{(.*)\}$/i', $component, $_get);
65 67
             if (!empty($_get[1]) && isset($_route[$index])) {
66 68
                 $get[array_pop($_get[1])] = $_route[$index];
Please login to merge, or discard this patch.
src/base/Service.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
401 401
             ]);
402 402
             $this->info['verbose'] = $verboseLog;
403 403
         }
404
-        Logger::log($this->url . ' response: ', LOG_DEBUG, $this->result);
404
+        Logger::log($this->url.' response: ', LOG_DEBUG, $this->result);
405 405
         $this->info = array_merge($this->info, curl_getinfo($this->con));
406 406
     }
407 407
 
Please login to merge, or discard this patch.
src/base/Request.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public static function header($name, $default = null)
147 147
     {
148
-        return self::getInstance()->getHeader($name,  $default);
148
+        return self::getInstance()->getHeader($name, $default);
149 149
     }
150 150
 
151 151
     /**
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
         $header = null;
159 159
         if ($this->hasHeader($name)) {
160 160
             $header = $this->header[$name];
161
-        } else if(array_key_exists('h_' . strtolower($name), $this->query)) {
162
-            $header = $this->query['h_' . strtolower($name)];
163
-        } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) {
164
-            $header = $this->server['HTTP_' . strtoupper(str_replace('-', '_', $name))];
161
+        }else if (array_key_exists('h_'.strtolower($name), $this->query)) {
162
+            $header = $this->query['h_'.strtolower($name)];
163
+        }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) {
164
+            $header = $this->server['HTTP_'.strtoupper(str_replace('-', '_', $name))];
165 165
         }
166 166
         return $header ?: $default;
167 167
     }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     {
259 259
         if (null === $url) $url = $this->getServer('HTTP_ORIGIN');
260 260
         ob_start();
261
-        header('Location: ' . $url);
261
+        header('Location: '.$url);
262 262
         ob_end_clean();
263 263
         Security::getInstance()->updateSession();
264 264
         exit(_('Redireccionando...'));
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
     {
303 303
         $url = $this->getServerName();
304 304
         $protocol = $protocol ? $this->getProtocol() : '';
305
-        if (!empty($protocol)) $url = $protocol . $url;
305
+        if (!empty($protocol)) $url = $protocol.$url;
306 306
         if (!in_array($this->getServer('SERVER_PORT'), [80, 443], true)) {
307
-            $url .= ':' . $this->getServer('SERVER_PORT');
307
+            $url .= ':'.$this->getServer('SERVER_PORT');
308 308
         }
309 309
         return $url;
310 310
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,7 +256,9 @@  discard block
 block discarded – undo
256 256
      */
257 257
     public function redirect($url = null)
258 258
     {
259
-        if (null === $url) $url = $this->getServer('HTTP_ORIGIN');
259
+        if (null === $url) {
260
+            $url = $this->getServer('HTTP_ORIGIN');
261
+        }
260 262
         ob_start();
261 263
         header('Location: ' . $url);
262 264
         ob_end_clean();
@@ -302,7 +304,9 @@  discard block
 block discarded – undo
302 304
     {
303 305
         $url = $this->getServerName();
304 306
         $protocol = $protocol ? $this->getProtocol() : '';
305
-        if (!empty($protocol)) $url = $protocol . $url;
307
+        if (!empty($protocol)) {
308
+            $url = $protocol . $url;
309
+        }
306 310
         if (!in_array($this->getServer('SERVER_PORT'), [80, 443], true)) {
307 311
             $url .= ':' . $this->getServer('SERVER_PORT');
308 312
         }
Please login to merge, or discard this patch.