Passed
Push — master ( 4fb9cd...1dadf3 )
by Fran
04:27
created
src/base/types/Form.php 3 patches
Doc Comments   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,6 +42,10 @@  discard block
 block discarded – undo
42 42
          * @return Form
43 43
          */
44 44
         public function setEncType($enctype) { $this->enctype = $enctype; return $this; }
45
+
46
+        /**
47
+         * @param string|null $action
48
+         */
45 49
         public function setAction($action) { $this->action = $action; return $this; }
46 50
         public function setMethod($method) { $this->method = $method; return $this; }
47 51
         public function setAttrs(array $attrs) { $this->attrs = $attrs; return $this; }
@@ -466,7 +470,7 @@  discard block
 block discarded – undo
466 470
         }
467 471
 
468 472
         /**
469
-         * @param $token_field
473
+         * @param string $token_field
470 474
          * @return bool
471 475
          */
472 476
         protected function existsFormToken($token_field) {
@@ -494,7 +498,7 @@  discard block
 block discarded – undo
494 498
         /**
495 499
          * Método que extrae el valor de un campo del formulario del modelo
496 500
          * @param $field
497
-         * @param $value
501
+         * @param ObjectCollection $value
498 502
          * @param $type
499 503
          * @return mixed
500 504
          */
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -156,7 +156,9 @@  discard block
 block discarded – undo
156 156
             //Validamos los campos del formulario
157 157
             if ($valid && count($this->fields) > 0) {
158 158
                 foreach ($this->fields as $key => &$field) {
159
-                    if ($key === $token_field || $key === self::SEPARATOR) continue;
159
+                    if ($key === $token_field || $key === self::SEPARATOR) {
160
+                        continue;
161
+                    }
160 162
                     list($field, $valid) = $this->checkFieldValidation($field, $key);
161 163
                 }
162 164
             }
@@ -442,7 +444,7 @@  discard block
 block discarded – undo
442 444
                     //Si es una relación múltiple
443 445
                     if ($value instanceof ObjectCollection) {
444 446
                         $field = $this->computeModelFieldValue($field, $value, $type);
445
-                    }else { //O una relación unitaria
447
+                    } else { //O una relación unitaria
446 448
                         if (method_exists($value, "__toString")) {
447 449
                             $field["value"] = $value;
448 450
                         } elseif ($value instanceof \DateTime) {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     use PSFS\base\Singleton;
13 13
     use PSFS\base\types\interfaces\FormType;
14 14
 
15
-    abstract class Form extends Singleton implements FormType{
15
+    abstract class Form extends Singleton implements FormType {
16 16
 
17 17
         /**
18 18
          * Variables de formulario
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
         public function __construct($model = null)
33 33
         {
34
-            if(null !== $model) {
34
+            if (null !== $model) {
35 35
                 $this->model = $model;
36 36
             }
37 37
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
          */
123 123
         public function getFieldValue($name) {
124 124
             $value = null;
125
-            if (null !== $this->getField($name)){
125
+            if (null !== $this->getField($name)) {
126 126
                 $field = $this->getField($name);
127 127
                 $value = (array_key_exists('value', $field) && null !== $field['value']) ? $field['value'] : null;
128 128
             }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
                 $model->save();
322 322
                 $save = true;
323 323
                 Logger::getInstance()->infoLog(get_class($this->model)." guardado con id ".$this->model->getPrimaryKey());
324
-            } catch (\Exception $e) {
324
+            }catch (\Exception $e) {
325 325
                 Logger::getInstance()->errorLog($e->getMessage());
326 326
                 throw new FormException($e->getMessage(), $e->getCode(), $e);
327 327
             }
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
         protected function checkEmpty($value) {
337 337
             $isEmpty = false;
338 338
             // NULL check
339
-            if(null === $value) {
339
+            if (null === $value) {
340 340
                 $isEmpty = true;
341 341
             // Empty Array check
342
-            } else if(is_array($value) && 0 === count($value)) {
342
+            }else if (is_array($value) && 0 === count($value)) {
343 343
                 $isEmpty = true;
344 344
             // Empty string check
345
-            } else if(0 === strlen(preg_replace('/(\ |\r|\n)/m', '', $value))) {
345
+            }else if (0 === strlen(preg_replace('/(\ |\r|\n)/m', '', $value))) {
346 346
                 $isEmpty = true;
347 347
             }
348 348
 
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
             if (array_key_exists($key, $data[$form_name])) {
389 389
                 if (preg_match("/id/i", $key) && ($data[$form_name][$key] === 0 || $data[$form_name][$key] === "%" || $data[$form_name][$key] === "")) {
390 390
                     $field["value"] = null;
391
-                } else {
391
+                }else {
392 392
                     $field["value"] = $data[$form_name][$key];
393 393
                 }
394
-            } else {
394
+            }else {
395 395
                 unset($field["value"]);
396 396
             }
397 397
             return array($data, $field);
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
                 if (array_key_exists('class_id', $field) && method_exists($class, "get".$field["class_id"])) {
436 436
                     $method = "get".$field["class_id"];
437 437
                     $data[] = $class->$method();
438
-                } else {
438
+                }else {
439 439
                     $data[] = $class->getPrimaryKey();
440 440
                 }
441
-            } else {
441
+            }else {
442 442
                 $data[] = $val;
443 443
             }
444 444
 
@@ -468,11 +468,11 @@  discard block
 block discarded – undo
468 468
                             $field["value"] = $value;
469 469
                         } elseif ($value instanceof \DateTime) {
470 470
                             $field["value"] = $value->format("Y-m-d H:i:s");
471
-                        } else {
471
+                        }else {
472 472
                             $field["value"] = $value->getPrimaryKey();
473 473
                         }
474 474
                     }
475
-                } else {
475
+                }else {
476 476
                     $field["value"] = $value;
477 477
                 }
478 478
             }
Please login to merge, or discard this patch.
src/base/dto/Order.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
         {
32 32
             $order = array();
33 33
             if (count($order) > 0) {
34
-                foreach($this->fields as $field => $direction) {
35
-                    if(strtolower($fieldToRemove) === strtolower($field)) {
34
+                foreach ($this->fields as $field => $direction) {
35
+                    if (strtolower($fieldToRemove) === strtolower($field)) {
36 36
                         continue;
37 37
                     }
38 38
                     $order[$field] = $direction;
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
          */
61 61
         public static function parseDirection($direction = Order::ASC)
62 62
         {
63
-            if(preg_match('/^asc$/i', $direction)) {
63
+            if (preg_match('/^asc$/i', $direction)) {
64 64
                 return Order::ASC;
65
-            } else {
65
+            }else {
66 66
                 return Order::DESC;
67 67
             }
68 68
         }
Please login to merge, or discard this patch.
src/base/extension/AssetsParser.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -303,7 +303,7 @@
 block discarded – undo
303 303
         $js = file_get_contents($file);
304 304
         try {
305 305
             $data .= ";\n".$js;
306
-        }catch (\Exception $e) {
306
+        } catch (\Exception $e) {
307 307
             throw new ConfigException($e->getMessage());
308 308
         }
309 309
         return $data;
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function setHash($hash)
88 88
     {
89
-	    $cache = Config::getInstance()->get('cache.var') ?: '';
90
-	    $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache;
89
+        $cache = Config::getInstance()->get('cache.var') ?: '';
90
+        $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache;
91 91
         return $this;
92 92
     }
93 93
 
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
         $file = "";
351 351
         $html_base = "";
352 352
         $debug = Config::getInstance()->getDebugMode();
353
-	    $cache = Config::getInstance()->get('cache.var');
354
-	    $cache = $cache ? '.'.$cache : '';
355
-	    if (preg_match('/\.css$/i', $string)) {
353
+        $cache = Config::getInstance()->get('cache.var');
354
+        $cache = $cache ? '.'.$cache : '';
355
+        if (preg_match('/\.css$/i', $string)) {
356 356
             $file = "/".substr(md5($string), 0, 8)."$cache.css";
357 357
             $html_base = "css";
358 358
             if ($debug) {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     public function setHash($hash)
88 88
     {
89 89
 	    $cache = Config::getInstance()->get('cache.var') ?: '';
90
-	    $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache;
90
+	    $this->hash = $hash.(strlen($cache) ? '.' : '').$cache;
91 91
         return $this;
92 92
     }
93 93
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             }
155 155
             try {
156 156
                 $minifiedJs = Minifier::minify($data);
157
-            } catch(\Exception $e) {
157
+            }catch (\Exception $e) {
158 158
                 Logger::log($e->getMessage(), LOG_ERR);
159 159
                 $minifiedJs = false;
160 160
             }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             foreach ($this->compiled_files as $file) {
198 198
                 echo "\t\t<script type='text/javascript' src='{$file}'></script>\n";
199 199
             }
200
-        } else {
200
+        }else {
201 201
             echo "\t\t<script type='text/javascript' src='/js/".$this->hash.".js'></script>\n";
202 202
         }
203 203
     }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             foreach ($this->compiled_files as $file) {
212 212
                 echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>";
213 213
             }
214
-        } else {
214
+        }else {
215 215
             echo "\t\t<link href='/css/".$this->hash.".css' rel='stylesheet'>";
216 216
         }
217 217
     }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
                     Logger::log("$orig copiado a $dest", LOG_INFO);
237 237
                 }
238 238
             }
239
-        } catch (\Exception $e) {
239
+        }catch (\Exception $e) {
240 240
             Logger::log($e->getMessage(), LOG_ERR);
241 241
         }
242 242
     }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             if ($this->debug) {
265 265
                 $data = file_get_contents($file);
266 266
                 $this->storeContents($base.$file_path, $data);
267
-            } else {
267
+            }else {
268 268
                 $data .= file_get_contents($file);
269 269
             }
270 270
             $this->compiled_files[] = "/css/".$file_path;
Please login to merge, or discard this patch.
src/base/extension/AssetsTokenParser.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
         $tmp = array();
136 136
         if (NULL === $node) {
137 137
             $node = $value;
138
-        }else {
138
+        } else {
139 139
             $tmp = $this->getTmpAttribute($node);
140 140
         }
141 141
         $tmp[] = $value->getAttribute("value");
Please login to merge, or discard this patch.
src/base/extension/TemplateFunctions.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
             $router = Router::getInstance();
53 53
             try {
54 54
                 return $router->getRoute($path, $absolute, $params);
55
-            } catch (\Exception $e)
55
+            }catch (\Exception $e)
56 56
             {
57 57
                 return $router->getRoute('', $absolute, $params);
58 58
             }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
          * @param string $path
137 137
          * @param $domains
138 138
          *
139
-         * @return mixed
139
+         * @return string
140 140
          */
141 141
         private static function extractPathname($path, $domains)
142 142
         {
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -179,8 +179,11 @@
 block discarded – undo
179 179
         private static function putResourceContent($name, $filename_path, $base, $file_path)
180 180
         {
181 181
             $data = file_get_contents($filename_path);
182
-            if (!empty($name)) file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data);
183
-            else file_put_contents($base.$file_path, $data);
182
+            if (!empty($name)) {
183
+                file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data);
184
+            } else {
185
+                file_put_contents($base.$file_path, $data);
186
+            }
184 187
         }
185 188
 
186 189
         /**
Please login to merge, or discard this patch.
src/command/PSFSConsole.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,14 +31,18 @@
 block discarded – undo
31 31
     //Hidratamos con los comandos de PSFS
32 32
     $commands = new Finder();
33 33
     $commands->in(__DIR__)->notName("PSFSConsole.php");
34
-    foreach ($commands as $com) include_once($com->getRealPath());
34
+    foreach ($commands as $com) {
35
+        include_once($com->getRealPath());
36
+    }
35 37
 
36 38
     //Hidratamos con los comandos de los módulos
37 39
     if (file_exists(CORE_DIR))
38 40
     {
39 41
         $commands = new Finder();
40 42
         $commands->in(CORE_DIR)->path("Command")->name("*.php");
41
-        foreach ($commands as $com) include_once($com->getRealPath());
43
+        foreach ($commands as $com) {
44
+            include_once($com->getRealPath());
45
+        }
42 46
     }
43 47
 
44 48
     $console->run();
Please login to merge, or discard this patch.
src/base/dto/Form.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         {
22 22
             $array = array();
23 23
             $array['fields'] = array();
24
-            foreach($this->fields as $field) {
24
+            foreach ($this->fields as $field) {
25 25
                 $array['fields'][] = $field->__toArray();
26 26
             }
27 27
             return $array;
Please login to merge, or discard this patch.
src/base/types/AuthApi.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
         {
27 27
             $namespace = explode('\\', $this->getModelTableMap());
28 28
             $module = strtolower($namespace[0]);
29
-            $secret = Config::getInstance()->get($module . '.api.secret');
29
+            $secret = Config::getInstance()->get($module.'.api.secret');
30 30
             if (NULL === $secret) {
31 31
                 $secret = Config::getInstance()->get("api.secret");
32 32
             }
33 33
             if (NULL === $secret) {
34 34
                 $auth = TRUE;
35
-            } else {
35
+            }else {
36 36
                 $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN');
37 37
                 if (array_key_exists('API_TOKEN', $this->query)) {
38 38
                     $token = $this->query['API_TOKEN'];
Please login to merge, or discard this patch.
src/services/DocumentorService.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -422,7 +422,7 @@
 block discarded – undo
422 422
                                 "type" => $type,
423 423
                             ];
424 424
                             if (strlen($format)) {
425
-                               $dto['properties'][$field]['format'] = $format;
425
+                                $dto['properties'][$field]['format'] = $format;
426 426
                             }
427 427
                         }
428 428
                     }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -339,7 +339,7 @@
 block discarded – undo
339 339
          * Translator from php types to swagger types
340 340
          * @param string $format
341 341
          *
342
-         * @return array
342
+         * @return string[]
343 343
          */
344 344
         public static function translateSwaggerFormats($format)
345 345
         {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
                         if (!preg_match('/^ROOT/i', $module)) {
40 40
                             $modules[] = [
41 41
                                 'name' => $module,
42
-                                'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'),
42
+                                'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'),
43 43
                             ];
44 44
                         }
45
-                    } catch (\Exception $e) {
45
+                    }catch (\Exception $e) {
46 46
                         $modules[] = $e->getMessage();
47 47
                     }
48 48
                 }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
          */
61 61
         public function extractApiEndpoints(array $module)
62 62
         {
63
-            $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api';
63
+            $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api';
64 64
             $module_name = $module['name'];
65 65
             $endpoints = [];
66 66
             if (file_exists($module_path)) {
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
                 if (count($finder)) {
70 70
                     /** @var \SplFileInfo $file */
71 71
                     foreach ($finder as $file) {
72
-                        $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename());
72
+                        $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename());
73 73
                         $info = $this->extractApiInfo($namespace, $module_name);
74
-                        if(!empty($info)) {
74
+                        if (!empty($info)) {
75 75
                             $endpoints[$namespace] = $info;
76 76
                         }
77 77
                     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         public function extractApiInfo($namespace, $module)
91 91
         {
92 92
             $info = [];
93
-            if(class_exists($namespace)) {
93
+            if (class_exists($namespace)) {
94 94
                 $reflection = new \ReflectionClass($namespace);
95 95
                 foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
96 96
                     try {
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                         if (NULL !== $mInfo) {
99 99
                             $info[] = $mInfo;
100 100
                         }
101
-                    } catch (\Exception $e) {
101
+                    }catch (\Exception $e) {
102 102
                         Logger::getInstance()->errorLog($e->getMessage());
103 103
                     }
104 104
                 }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
          */
257 257
         protected function extractReturn($model, $comments = '')
258 258
         {
259
-            $modelDto  = [];
259
+            $modelDto = [];
260 260
             preg_match('/\@return\ (.*)\((.*)\)\n/i', $comments, $returnTypes);
261 261
             if (count($returnTypes)) {
262 262
                 // Extract principal DTO information
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                 } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
310 310
                     $payload = $this->extractDtoProperties($namespace);
311 311
                 }
312
-            } catch (\Exception $e) {
312
+            }catch (\Exception $e) {
313 313
                 Logger::getInstance()->errorLog($e->getMessage());
314 314
             }
315 315
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                         if (in_array($methodInfo['method'], ['POST', 'PUT'])) {
347 347
                             $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments);
348 348
                         }
349
-                    } catch (\Exception $e) {
349
+                    }catch (\Exception $e) {
350 350
                         jpre($e->getMessage());
351 351
                         Logger::getInstance()->errorLog($e->getMessage());
352 352
                     }
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
          */
365 365
         public static function translateSwaggerFormats($format)
366 366
         {
367
-            switch(strtolower($format)) {
367
+            switch (strtolower($format)) {
368 368
                 case 'bool':
369 369
                 case 'boolean':
370 370
                     $swaggerType = 'boolean';
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
                             ]]);
426 426
                             if (array_key_exists($subDtoName, $subDto)) {
427 427
                                 $definitions = $subDto;
428
-                            } else {
428
+                            }else {
429 429
                                 $definitions[$subDtoName] = $subDto;
430 430
                             }
431 431
                             $dto['properties'][$field] = [
432
-                                '$ref' => "#/definitions/" . $subDtoName,
432
+                                '$ref' => "#/definitions/".$subDtoName,
433 433
                             ];
434
-                        } else {
434
+                        }else {
435 435
                             list($type, $format) = self::translateSwaggerFormats($format);
436 436
                             $dto['properties'][$field] = [
437 437
                                 "type" => $type,
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
                     ]
471 471
                 ]
472 472
             ];
473
-            foreach($endpoints as $model) {
473
+            foreach ($endpoints as $model) {
474 474
                 foreach ($model as $endpoint) {
475 475
                     $dtos += self::extractSwaggerDefinition($endpoint);
476 476
                 }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         protected function extractDtoName($dto, $isArray = false)
490 490
         {
491 491
             $dto = explode('\\', $dto);
492
-            $modelDto = array_pop($dto) . "Dto";
492
+            $modelDto = array_pop($dto)."Dto";
493 493
             if ($isArray) {
494 494
                 $modelDto .= "List";
495 495
             }
Please login to merge, or discard this patch.