Passed
Push — master ( bf062d...6e413a )
by Fran
04:24
created
src/base/dto/Dto.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __construct($hydrate = true)
20 20
     {
21 21
         parent::__construct();
22
-        if($hydrate) {
22
+        if ($hydrate) {
23 23
             $this->fromArray(Request::getInstance()->getData());
24 24
         }
25 25
     }
@@ -47,23 +47,23 @@  discard block
 block discarded – undo
47 47
                 /** @var \ReflectionProperty $property */
48 48
                 foreach ($properties as $property) {
49 49
                     $value = $property->getValue($this);
50
-                    if(is_object($value) && method_exists($value, 'toArray')) {
50
+                    if (is_object($value) && method_exists($value, 'toArray')) {
51 51
                         $dto[$property->getName()] = $value->toArray();
52
-                    } elseif(is_array($value)) {
53
-                        foreach($value as &$arrValue) {
54
-                            if($arrValue instanceof Dto) {
52
+                    } elseif (is_array($value)) {
53
+                        foreach ($value as &$arrValue) {
54
+                            if ($arrValue instanceof Dto) {
55 55
                                 $arrValue = $arrValue->toArray();
56 56
                             }
57 57
                         }
58 58
                         $dto[$property->getName()] = $value;
59
-                    } else {
59
+                    }else {
60 60
                         $type = InjectorHelper::extractVarType($property->getDocComment());
61 61
                         $dto[$property->getName()] = $this->checkCastedValue($property->getValue($this), $type);
62 62
                     }
63 63
                 }
64 64
             }
65
-        } catch (\Exception $e) {
66
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
65
+        }catch (\Exception $e) {
66
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
67 67
         }
68 68
         return $dto;
69 69
     }
@@ -86,26 +86,26 @@  discard block
 block discarded – undo
86 86
     protected function parseDtoField(array $properties, $key, $value = null) {
87 87
         list($type, $isArray) = $this->extractTypes($properties, $key);
88 88
         $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null;
89
-        if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
90
-            if(null !== $value && is_array($value)) {
91
-                if(!array_key_exists($type, $this->__cache)) {
89
+        if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
90
+            if (null !== $value && is_array($value)) {
91
+                if (!array_key_exists($type, $this->__cache)) {
92 92
                     $this->__cache[$type] = new $type(false);
93 93
                 }
94
-                if($isArray) {
94
+                if ($isArray) {
95 95
                     $this->$key = [];
96
-                    foreach($value as $data) {
97
-                        if(null !== $data && is_array($data)) {
96
+                    foreach ($value as $data) {
97
+                        if (null !== $data && is_array($data)) {
98 98
                             $dto = clone $this->__cache[$type];
99 99
                             $dto->fromArray($data);
100 100
                             array_push($this->$key, $dto);
101 101
                         }
102 102
                     }
103
-                } else {
103
+                }else {
104 104
                     $this->$key = clone $this->__cache[$type];
105 105
                     $this->$key->fromArray($value);
106 106
                 }
107 107
             }
108
-        } else {
108
+        }else {
109 109
             $this->castValue($key, $value, $type);
110 110
         }
111 111
     }
Please login to merge, or discard this patch.
src/controller/RouteController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
             $router->simpatize();
58 58
             Security::getInstance()->setFlash("callback_message", t("Rutas generadas correctamente"));
59 59
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
60
-        } catch (Exception $e) {
60
+        }catch (Exception $e) {
61 61
             Logger::log($e->getMessage(), LOG_ERR);
62 62
             Security::getInstance()->setFlash("callback_message", t("Algo no ha salido bien, revisa los logs"));
63 63
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
Please login to merge, or discard this patch.
src/controller/ConfigController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         foreach ($domains as $domain => $routes) {
34 34
             $pDomain = str_replace('@', '', $domain);
35 35
             $pDomain = str_replace('/', '', $pDomain);
36
-            $response[] = strtolower($pDomain) . '.api.secret';
36
+            $response[] = strtolower($pDomain).'.api.secret';
37 37
         }
38 38
         return $this->json($response);
39 39
     }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function config()
51 51
     {
52
-        Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri());
52
+        Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri());
53 53
         /* @var $form ConfigForm */
54 54
         $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig());
55 55
         $form->build();
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 }
87 87
                 Security::getInstance()->setFlash("callback_message", t("Configuración actualizada correctamente"));
88 88
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true));
89
-            } else {
89
+            }else {
90 90
                 throw new HttpException(t('Error al guardar la configuración, prueba a cambiar los permisos'), 403);
91 91
             }
92 92
         }
Please login to merge, or discard this patch.
src/controller/GeneratorController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function generateModule()
36 36
     {
37
-        Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri());
37
+        Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri());
38 38
         /* @var $form ConfigForm */
39 39
         $form = new ModuleForm();
40 40
         $form->build();
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
                 $this->gen->createStructureModule($module, false, $type, $apiClass);
67 67
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente")));
68 68
                 // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
69
-            } catch (Exception $e) {
70
-                Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
69
+            }catch (Exception $e) {
70
+                Logger::log($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
71 71
                 Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage()));
72 72
             }
73 73
         }
Please login to merge, or discard this patch.
src/base/Singleton.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function __construct()
28 28
     {
29
-        Logger::log(static::class . ' constructor invoked');
29
+        Logger::log(static::class.' constructor invoked');
30 30
         $this->init();
31 31
     }
32 32
 
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
         $calledClass = static::class;
86 86
         try {
87 87
             $instance = InjectorHelper::constructInjectableInstance($variable, $singleton, $classNameSpace, $calledClass);
88
-            $setter = 'set' . ucfirst($variable);
88
+            $setter = 'set'.ucfirst($variable);
89 89
             if (method_exists($calledClass, $setter)) {
90 90
                 $this->$setter($instance);
91
-            } else {
91
+            }else {
92 92
                 $this->$variable = $instance;
93 93
             }
94
-        } catch (Exception $e) {
95
-            Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR);
94
+        }catch (Exception $e) {
95
+            Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR);
96 96
             throw $e;
97 97
         }
98 98
         return $this;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     {
108 108
         if (!$this->isLoaded()) {
109 109
             $filename = sha1(get_class($this));
110
-            $cacheFilename = 'reflections' . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . '.json';
110
+            $cacheFilename = 'reflections'.DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.'.json';
111 111
             /** @var Cache $cacheService */
112 112
             $cacheService = Cache::getInstance();
113 113
             /** @var Config $configService */
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
                 }
126 126
             }
127 127
             $this->setLoaded();
128
-        } else {
129
-            Logger::log(get_class($this) . ' already loaded', LOG_INFO);
128
+        }else {
129
+            Logger::log(get_class($this).' already loaded', LOG_INFO);
130 130
         }
131 131
     }
132 132
 }
Please login to merge, or discard this patch.
src/base/Request.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public static function header($name, $default = null)
124 124
     {
125
-        return self::getInstance()->getHeader($name,  $default);
125
+        return self::getInstance()->getHeader($name, $default);
126 126
     }
127 127
 
128 128
     /**
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
         $header = null;
136 136
         if ($this->hasHeader($name)) {
137 137
             $header = $this->header[$name];
138
-        } else if(array_key_exists('h_' . strtolower($name), $this->query)) {
139
-            $header = $this->query['h_' . strtolower($name)];
140
-        } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) {
141
-            $header = $this->getServer('HTTP_' . strtoupper(str_replace('-', '_', $name)));
138
+        }else if (array_key_exists('h_'.strtolower($name), $this->query)) {
139
+            $header = $this->query['h_'.strtolower($name)];
140
+        }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) {
141
+            $header = $this->getServer('HTTP_'.strtoupper(str_replace('-', '_', $name)));
142 142
         }
143 143
         return $header ?: $default;
144 144
     }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
             $url = $this->getServer('HTTP_ORIGIN');
243 243
         }
244 244
         ob_start();
245
-        header('Location: ' . $url);
245
+        header('Location: '.$url);
246 246
         ob_end_clean();
247 247
         Security::getInstance()->updateSession();
248 248
         exit(t('Redirect...'));
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         $url = $this->getServerName();
259 259
         $protocol = $hasProtocol ? $this->getProtocol() : '';
260 260
         if (!empty($protocol)) {
261
-            $url = $protocol . $url;
261
+            $url = $protocol.$url;
262 262
         }
263 263
         $url = $this->checkServerPort($url);
264 264
         return $url;
@@ -272,15 +272,15 @@  discard block
 block discarded – undo
272 272
     {
273 273
         $port = (integer)$this->getServer('SERVER_PORT');
274 274
         $host = $this->getServer('HTTP_HOST');
275
-        if(!empty($host)) {
275
+        if (!empty($host)) {
276 276
             $parts = explode(':', $host);
277 277
             $hostPort = (integer)end($parts);
278
-            if(count($parts) > 1 && $hostPort !== $port) {
278
+            if (count($parts) > 1 && $hostPort !== $port) {
279 279
                 $port = $hostPort;
280 280
             }
281 281
         }
282 282
         if (!in_array($port, [80, 443], true)) {
283
-            $url .= ':' . $port;
283
+            $url .= ':'.$port;
284 284
         }
285 285
         return $url;
286 286
     }
Please login to merge, or discard this patch.
src/base/types/traits/Helper/ServerTrait.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
     public function getServer($key, $default = null)
22 22
     {
23 23
         $value = null;
24
-        if(array_key_exists($key, $this->server)) {
24
+        if (array_key_exists($key, $this->server)) {
25 25
             $value = $this->server[$key];
26 26
         }
27 27
         return $value ?: $default;
Please login to merge, or discard this patch.
src/base/types/helpers/ApiFormHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
     public static function checkApiActions($namespace, $domain, $api) {
20 20
         $actions = [];
21 21
         $reflector = new ReflectionClass($namespace);
22
-        if(null !== $reflector) {
23
-            foreach($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $apiAction) {
22
+        if (null !== $reflector) {
23
+            foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $apiAction) {
24 24
                 $docComments = $apiAction->getDocComment();
25 25
                 $action = AnnotationHelper::extractAction($docComments);
26
-                if(null !== $action) {
26
+                if (null !== $action) {
27 27
                     list($route, $info) = RouterHelper::extractRouteInfo($apiAction, $api, $domain);
28 28
                     list($method, $cleanRoute) = RouterHelper::extractHttpRoute($route);
29 29
                     $formAction = new FormAction();
Please login to merge, or discard this patch.
src/base/types/helpers/InjectorHelper.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
                 $label = self::getLabel($property->getDocComment());
32 32
                 $values = self::getValues($property->getDocComment());
33 33
                 $isArray = (bool)preg_match('/\[\]$/', $instanceType);
34
-                if($isArray) {
34
+                if ($isArray) {
35 35
                     $instanceType = str_replace('[]', '', $instanceType);
36 36
                 }
37
-                if($instanceType === '\\DateTime' || !Router::exists($instanceType)) {
37
+                if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) {
38 38
                     list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType);
39 39
                     $variables[$property->getName()] = [
40 40
                         'type' => $type,
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                         'required' => $isRequired,
43 43
                         'description' => $label,
44 44
                     ];
45
-                } else {
45
+                }else {
46 46
                     $instance = new ReflectionClass($instanceType);
47 47
                     $variables[$property->getName()] = [
48 48
                         'is_array' => $isArray,
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                         'properties' => self::extractVariables($instance),
52 52
                     ];
53 53
                 }
54
-                if(!empty($values)){
54
+                if (!empty($values)) {
55 55
                     $variables[$property->getName()]['enum'] = $values;
56 56
                 }
57 57
             }
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public static function constructInjectableInstance($variable, $singleton, $classNameSpace, $calledClass)
157 157
     {
158
-        Logger::log('Create inyectable instance for ' . $classNameSpace);
158
+        Logger::log('Create inyectable instance for '.$classNameSpace);
159 159
         $reflector = new ReflectionClass($calledClass);
160 160
         $property = $reflector->getProperty($variable);
161 161
         $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace;
162 162
         if (true === $singleton && method_exists($varInstanceType, 'getInstance')) {
163 163
             $instance = $varInstanceType::getInstance();
164
-        } else {
164
+        }else {
165 165
             $instance = new $varInstanceType();
166 166
         }
167 167
         return $instance;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
     public static function getClassProperties($class)
176 176
     {
177 177
         $properties = [];
178
-        Logger::log('Extracting annotations properties from class ' . $class);
178
+        Logger::log('Extracting annotations properties from class '.$class);
179 179
         $selfReflector = new ReflectionClass($class);
180 180
         if (false !== $selfReflector->getParentClass()) {
181 181
             $properties = self::getClassProperties($selfReflector->getParentClass()->getName());
Please login to merge, or discard this patch.