Passed
Push — master ( dd9457...9bc0cf )
by Fran
03:07
created
src/base/types/traits/Api/ManagerTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@
 block discarded – undo
39 39
             "domain" => $this->getDomain(),
40 40
             "listLabel" => Api::API_LIST_NAME_FIELD,
41 41
             'modelId' => Api::API_MODEL_KEY_FIELD,
42
-            'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)),
43
-            "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)),
42
+            'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)),
43
+            "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)),
44 44
         ), [], '');
45 45
     }
46 46
 
Please login to merge, or discard this patch.
src/base/types/Controller.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
     public function render($template, array $vars = array(), $cookies = array(), $domain = null)
42 42
     {
43 43
         $vars['__menu__'] = $this->getMenu();
44
-        if(Config::getParam('profiling.enable')) {
44
+        if (Config::getParam('profiling.enable')) {
45 45
             $vars['__profiling__'] = Inspector::getStats();
46 46
         }
47 47
         $domain = (null === $domain) ? $this->getDomain() : $domain;
48
-        return $this->tpl->render($domain . $template, $vars, $cookies);
48
+        return $this->tpl->render($domain.$template, $vars, $cookies);
49 49
     }
50 50
 
51 51
     /**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $vars['__menu__'] = $this->getMenu();
78 78
         $domain = $domain ?: $this->getDomain();
79
-        return $this->tpl->dump($domain . $template, $vars);
79
+        return $this->tpl->dump($domain.$template, $vars);
80 80
     }
81 81
 
82 82
     /**
Please login to merge, or discard this patch.
src/base/config/ConfigForm.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@
 block discarded – undo
82 82
             "class" => "btn-warning md-default",
83 83
             "icon" => "fa-plus",
84 84
         ];
85
-        if(Config::getParam('admin.version', 'v1') === 'v1') {
86
-            $add["onclick"] = "javascript:addNewField(document.getElementById('" . $this->getName() . "'));";
87
-        } else {
85
+        if (Config::getParam('admin.version', 'v1') === 'v1') {
86
+            $add["onclick"] = "javascript:addNewField(document.getElementById('".$this->getName()."'));";
87
+        }else {
88 88
             $add["ng-click"] = "addNewField()";
89 89
         }
90 90
         $this->addButton('submit', _("Guardar configuración"), "submit", array(
Please login to merge, or discard this patch.
src/base/types/helpers/Inspector.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     protected static function calculateStats(array $stats, $ts, $mem = 0, $files = 0) {
29 29
         return [
30 30
             'ts' => round($stats['ts'] - $ts, 4),
31
-            'mem' => round(($stats['mem'] - $mem) / 1024 / 1024, 4),
31
+            'mem' => round(($stats['mem'] - $mem)/1024/1024, 4),
32 32
             'files' => $stats['files'] - $files,
33 33
             'name' => $stats['name'],
34 34
         ];
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $ts = defined('PSFS_START_TS') ? PSFS_START_TS : 0;
43 43
         $mem = defined('PSFS_START_MEM') ? PSFS_START_MEM : 0;
44 44
         $files = 0;
45
-        foreach(self::$profiling as $key => &$value) {
45
+        foreach (self::$profiling as $key => &$value) {
46 46
             $value = self::calculateStats($value, $ts, $mem, $files);
47 47
         }
48 48
         self::$profiling[] = self::calculateStats(self::collect('Profiling collect ends'), $ts, $mem, $files);
Please login to merge, or discard this patch.
src/base/dto/Dto.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     public function __construct($hydrate = true)
19 19
     {
20 20
         parent::__construct();
21
-        if($hydrate) {
21
+        if ($hydrate) {
22 22
             $this->fromArray(Request::getInstance()->getData());
23 23
         }
24 24
     }
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
                 /** @var \ReflectionProperty $property */
47 47
                 foreach ($properties as $property) {
48 48
                     $value = $property->getValue($this);
49
-                    if(is_object($value) && method_exists($value, 'toArray')) {
49
+                    if (is_object($value) && method_exists($value, 'toArray')) {
50 50
                         $dto[$property->getName()] = $value->toArray();
51
-                    } else {
51
+                    }else {
52 52
                         $dto[$property->getName()] = $property->getValue($this);
53 53
                     }
54 54
                 }
55 55
             }
56
-        } catch (\Exception $e) {
57
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
56
+        }catch (\Exception $e) {
57
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
58 58
         }
59 59
         return $dto;
60 60
     }
@@ -76,32 +76,32 @@  discard block
 block discarded – undo
76 76
     protected function parseDtoField(array $properties, $key, $value = null) {
77 77
         $type = 'string';
78 78
         $is_array = false;
79
-        if(array_key_exists($key, $properties)) {
79
+        if (array_key_exists($key, $properties)) {
80 80
             $type = $properties[$key];
81
-            if(preg_match('/(\[\]|Array)/i', $type)) {
81
+            if (preg_match('/(\[\]|Array)/i', $type)) {
82 82
                 $type = preg_replace('/(\[\]|Array)/i', '', $type);
83 83
                 $is_array = true;
84 84
             }
85 85
         }
86 86
         $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null;
87
-        if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
88
-            if(null !== $value && is_array($value)) {
89
-                if($is_array) {
87
+        if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
88
+            if (null !== $value && is_array($value)) {
89
+                if ($is_array) {
90 90
                     $this->$key = [];
91
-                    foreach($value as $data) {
92
-                        if(null !== $data && is_array($data)) {
91
+                    foreach ($value as $data) {
92
+                        if (null !== $data && is_array($data)) {
93 93
                             $dto = new $type(false);
94 94
                             $dto->fromArray($data);
95 95
                             array_push($this->$key, $dto);
96 96
                         }
97 97
                     }
98
-                } else {
98
+                }else {
99 99
                     $this->$key = new $type(false);
100 100
                     $this->$key->fromArray($value);
101 101
                 }
102 102
             }
103
-        } else {
104
-            switch($type) {
103
+        }else {
104
+            switch ($type) {
105 105
                 default:
106 106
                 case 'string':
107 107
                     $this->$key = $value;
Please login to merge, or discard this patch.
src/base/types/helpers/DocumentorHelper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
      */
15 15
     private static function searchPayloadParam($params, $variable) {
16 16
         $exists = false;
17
-        if(null !== $params && count($params)) {
18
-            foreach($params as $param) {
19
-                if($param['name'] === $variable) {
17
+        if (null !== $params && count($params)) {
18
+            foreach ($params as $param) {
19
+                if ($param['name'] === $variable) {
20 20
                     $exists = true;
21 21
                     break;
22 22
                 }
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
         ];
41 41
         if ($endpoint['payload']['is_array']) {
42 42
             $schema['items'] = [
43
-                '$ref' => '#/definitions/' . $endpoint['payload']['type'],
43
+                '$ref' => '#/definitions/'.$endpoint['payload']['type'],
44 44
             ];
45
-        } else {
46
-            $schema['$ref'] = '#/definitions/' . $endpoint['payload']['type'];
45
+        }else {
46
+            $schema['$ref'] = '#/definitions/'.$endpoint['payload']['type'];
47 47
         }
48
-        if(!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) {
48
+        if (!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) {
49 49
             $paths[$url][$method]['parameters'][] = [
50 50
                 'in' => 'body',
51 51
                 'name' => $endpoint['payload']['type'],
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
             if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) {
75 75
                 $classDefinition = [
76 76
                     'type' => 'object',
77
-                    '$ref' => '#/definitions/' . $class,
77
+                    '$ref' => '#/definitions/'.$class,
78 78
                 ];
79
-            } else {
79
+            }else {
80 80
                 $classDefinition = [
81 81
                     'type' => 'array',
82 82
                     'items' => [
83
-                        '$ref' => '#/definitions/' . $class,
83
+                        '$ref' => '#/definitions/'.$class,
84 84
                     ],
85 85
                 ];
86 86
             }
87 87
 
88
-            if($paths[$url][$method]['responses'][200]['schema']['properties']['data']['type'] === 'boolean') {
88
+            if ($paths[$url][$method]['responses'][200]['schema']['properties']['data']['type'] === 'boolean') {
89 89
                 $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition;
90 90
             }
91 91
             $dtos += self::extractSwaggerDefinition($class, $object);
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
             ],
164 164
         ];
165 165
         foreach ($fields as $field => $info) {
166
-            if(array_key_exists('type', $info) || in_array($info['type'], ['array', 'object'])) {
166
+            if (array_key_exists('type', $info) || in_array($info['type'], ['array', 'object'])) {
167 167
                 $definition[$name]['properties'][$field] = $info;
168
-            } else {
168
+            }else {
169 169
                 list($type, $format) = self::translateSwaggerFormats($info['type']);
170 170
                 $fieldData = [
171 171
                     "type" => $type,
172 172
                     "required" => $info['required'],
173 173
                 ];
174
-                if(array_key_exists('description', $info)) {
174
+                if (array_key_exists('description', $info)) {
175 175
                     $fieldData['description'] = $info['description'];
176 176
                 }
177
-                if(array_key_exists('format', $info)) {
177
+                if (array_key_exists('format', $info)) {
178 178
                     $fieldData['format'] = $info['format'];
179 179
                 }
180 180
                 $dto['properties'][$field] = $fieldData;
Please login to merge, or discard this patch.
src/base/types/helpers/FileHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function readFile($path) {
25 25
         $data = false;
26
-        if(file_exists($path)) {
26
+        if (file_exists($path)) {
27 27
             $data = @file_get_contents($path);
28 28
         }
29 29
         return $data;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @return string
37 37
      */
38 38
     public static function generateHashFilename($verb, $slug, array $query = []) {
39
-        return sha1(strtolower($verb) . ' ' . $slug . ' ' . strtolower(http_build_query($query)));
39
+        return sha1(strtolower($verb).' '.$slug.' '.strtolower(http_build_query($query)));
40 40
     }
41 41
 
42 42
     /**
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
     public static function generateCachePath(array $action, array $query = []) {
48 48
         $class = GeneratorHelper::extractClassFromNamespace($action['class']);
49 49
         $filename = self::generateHashFilename($action['http'], $action['slug'], $query);
50
-        $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2);
51
-        return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR;
50
+        $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2);
51
+        return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR;
52 52
     }
53 53
 
54 54
     /**
Please login to merge, or discard this patch.
src/base/types/helpers/InjectorHelper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
                 $isRequired = self::checkIsRequired($property->getDocComment());
28 28
                 $label = self::getLabel($property->getDocComment());
29 29
                 $isArray = (bool)preg_match('/\[\]$/', $instanceType);
30
-                if($isArray) {
30
+                if ($isArray) {
31 31
                     $instanceType = str_replace('[]', '', $instanceType);
32 32
                 }
33
-                if($instanceType === '\\DateTime' || !Router::exists($instanceType)) {
33
+                if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) {
34 34
                     list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType);
35 35
                     $variables[$property->getName()] = [
36 36
                         'type' => $type,
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
                         'required' => $isRequired,
39 39
                         'description' => $label,
40 40
                     ];
41
-                } else {
41
+                }else {
42 42
                     $instance = new \ReflectionClass($instanceType);
43 43
                     $variables[$property->getName()] = [
44 44
                         'is_array' => $isArray,
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         // Extract description
125 125
         $label = null;
126 126
         preg_match('/@label\ (.*)\n/i', $doc, $matches);
127
-        if(count($matches)) {
127
+        if (count($matches)) {
128 128
             $label = _($matches[1]);
129 129
         }
130 130
         return $label;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     public static function getDefaultValue($doc) {
138 138
         $default = null;
139 139
         preg_match('/@default\ (.*)\n/i', $doc, $matches);
140
-        if(count($matches)) {
140
+        if (count($matches)) {
141 141
             $default = $matches[1];
142 142
         }
143 143
         return $default;
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass)
154 154
     {
155
-        Logger::log('Create inyectable instance for ' . $classNameSpace);
155
+        Logger::log('Create inyectable instance for '.$classNameSpace);
156 156
         $reflector = new \ReflectionClass($calledClass);
157 157
         $property = $reflector->getProperty($variable);
158 158
         $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace;
159 159
         if (true === $singleton && method_exists($varInstanceType, 'getInstance')) {
160 160
             $instance = $varInstanceType::getInstance();
161
-        } else {
161
+        }else {
162 162
             $instance = new $varInstanceType();
163 163
         }
164 164
         return $instance;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     public static function getClassProperties($class)
173 173
     {
174 174
         $properties = [];
175
-        Logger::log('Extracting annotations properties from class ' . $class);
175
+        Logger::log('Extracting annotations properties from class '.$class);
176 176
         $selfReflector = new \ReflectionClass($class);
177 177
         if (false !== $selfReflector->getParentClass()) {
178 178
             $properties = self::getClassProperties($selfReflector->getParentClass()->getName());
Please login to merge, or discard this patch.
src/base/Cache.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         GeneratorHelper::createDir(dirname($path));
56 56
         if (false === FileHelper::writeFile($path, $data)) {
57
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
57
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path);
58 58
         }
59 59
     }
60 60
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]);
70 70
         $data = null;
71
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
71
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
72 72
         if (file_exists($absolutePath)) {
73 73
             $data = FileHelper::readFile($absolutePath);
74 74
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
85 85
     {
86 86
         Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]);
87
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
87
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
88 88
         $lasModificationDate = filemtime($absolutePath);
89 89
         return ($lasModificationDate + $expires <= time());
90 90
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         Logger::log('Store data in cache', LOG_DEBUG, ['path' => $path]);
153 153
         $data = self::transformData($data, $transform);
154
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
154
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
155 155
         $this->saveTextToFile($data, $absolutePath);
156 156
     }
157 157
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $data = null;
170 170
         Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]);
171
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
172 172
             if (is_callable($function) && $this->hasExpiredCache($path, $expires)) {
173 173
                 $data = $function();
174 174
                 $this->storeData($path, $data, $transform, false, $expires);
175
-            } else {
175
+            }else {
176 176
                 $data = $this->getDataFromFile($path, $transform);
177 177
             }
178 178
         }
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     public function flushCache() {
227
-        if(Config::getParam('cache.data.enable', false)) {
227
+        if (Config::getParam('cache.data.enable', false)) {
228 228
             Logger::log('Flushing cache', LOG_DEBUG);
229 229
             $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR);
230
-            if(is_array($action)) {
231
-                $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
232
-                if(!file_exists($hashPath)) {
233
-                    $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath;
230
+            if (is_array($action)) {
231
+                $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
232
+                if (!file_exists($hashPath)) {
233
+                    $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath;
234 234
                 }
235 235
                 FileHelper::deleteDir($hashPath);
236 236
             }
Please login to merge, or discard this patch.