Passed
Push — master ( 0a9e87...9dd3d7 )
by Fran
03:31
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/CreateModule.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,12 +29,16 @@  discard block
 block discarded – undo
29 29
 
30 30
             public function infoLog($msg)
31 31
             {
32
-                if ($this->verbosity) $this->log->writeln($msg);
32
+                if ($this->verbosity) {
33
+                    $this->log->writeln($msg);
34
+                }
33 35
             }
34 36
         }
35 37
     }
36 38
 
37
-    if (!isset($console)) $console = new Application();
39
+    if (!isset($console)) {
40
+        $console = new Application();
41
+    }
38 42
     $console
39 43
         ->register('psfs:create:module')
40 44
         ->setDefinition(array(
@@ -58,7 +62,7 @@  discard block
 block discarded – undo
58 62
                 {
59 63
                     \PSFS\services\GeneratorService::getInstance()->createStructureModule($module, $log);
60 64
                 }
61
-            }catch (\Exception $e)
65
+            } catch (\Exception $e)
62 66
             {
63 67
                 $output->writeln($e->getMessage());
64 68
                 $output->writeln($e->getTraceAsString());
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.