Passed
Push — master ( 14f6bb...8d1d43 )
by Fran
07:59 queued 04:09
created
src/base/dto/JsonResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
         $this->success = $result;
43 43
         $this->total = $total ?: count($data);
44 44
         $this->pages = $pages;
45
-        if(null !== $message) {
45
+        if (null !== $message) {
46 46
             $this->message = $message;
47 47
         }
48 48
     }
Please login to merge, or discard this patch.
src/base/types/Api.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -3,15 +3,12 @@
 block discarded – undo
3 3
 
4 4
 use Propel\Runtime\ActiveQuery\ModelCriteria;
5 5
 use Propel\Runtime\Map\TableMap;
6
-use PSFS\base\config\Config;
7 6
 use PSFS\base\dto\JsonResponse;
8 7
 use PSFS\base\dto\Order;
9 8
 use PSFS\base\Logger;
10 9
 use PSFS\base\Request;
11
-use PSFS\base\Security;
12 10
 use PSFS\base\Singleton;
13 11
 use PSFS\base\types\helpers\ApiHelper;
14
-use PSFS\base\types\helpers\Inspector;
15 12
 use PSFS\base\types\traits\Api\ManagerTrait;
16 13
 
17 14
 /**
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
     public function init()
72 72
     {
73 73
         parent::init();
74
-        Logger::log(get_called_class() . ' init', LOG_DEBUG);
74
+        Logger::log(get_called_class().' init', LOG_DEBUG);
75 75
         $this->domain = $this->getDomain();
76 76
         $this->hydrateRequestData();
77 77
         $this->hydrateOrders();
78 78
         $this->createConnection($this->getTableMap());
79 79
         $this->setLoaded(true);
80
-        Logger::log(get_called_class() . ' loaded', LOG_DEBUG);
80
+        Logger::log(get_called_class().' loaded', LOG_DEBUG);
81 81
     }
82 82
 
83 83
     /**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     private function hydrateOrders()
87 87
     {
88 88
         if (count($this->query)) {
89
-            Logger::log(get_called_class() . ' gathering query string', LOG_DEBUG);
89
+            Logger::log(get_called_class().' gathering query string', LOG_DEBUG);
90 90
             foreach ($this->query as $key => $value) {
91 91
                 if ($key === self::API_ORDER_FIELD) {
92 92
                     foreach ($value as $field => $direction) {
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
      */
104 104
     protected function extractPagination()
105 105
     {
106
-        Logger::log(get_called_class() . ' extract pagination start', LOG_DEBUG);
106
+        Logger::log(get_called_class().' extract pagination start', LOG_DEBUG);
107 107
         $page = (array_key_exists(self::API_PAGE_FIELD, $this->query)) ? $this->query[self::API_PAGE_FIELD] : 1;
108 108
         $limit = (array_key_exists(self::API_LIMIT_FIELD, $this->query)) ? $this->query[self::API_LIMIT_FIELD] : 100;
109
-        Logger::log(get_called_class() . ' extract pagination end', LOG_DEBUG);
109
+        Logger::log(get_called_class().' extract pagination end', LOG_DEBUG);
110 110
         return array($page, $limit);
111 111
     }
112 112
 
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
      *
116 116
      * @param ModelCriteria $query
117 117
      */
118
-    private function addOrders(ModelCriteria &$query)
118
+    private function addOrders(ModelCriteria & $query)
119 119
     {
120
-        Logger::log(get_called_class() . ' extract orders start ', LOG_DEBUG);
120
+        Logger::log(get_called_class().' extract orders start ', LOG_DEBUG);
121 121
         $orderAdded = FALSE;
122 122
         $tableMap = $this->getTableMap();
123 123
         foreach ($this->order->getOrders() as $field => $direction) {
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
                 $orderAdded = TRUE;
126 126
                 if ($direction === Order::ASC) {
127 127
                     $query->addAscendingOrderByColumn($column->getPhpName());
128
-                } else {
128
+                }else {
129 129
                     $query->addDescendingOrderByColumn($column->getPhpName());
130 130
                 }
131 131
             }
132 132
         }
133 133
         if (!$orderAdded) {
134
-            foreach($this->getPkDbName() as $pk => $phpName) {
134
+            foreach ($this->getPkDbName() as $pk => $phpName) {
135 135
                 $query->addAscendingOrderByColumn($pk);
136 136
             }
137 137
         }
138
-        Logger::log(get_called_class() . ' extract orders end', LOG_DEBUG);
138
+        Logger::log(get_called_class().' extract orders end', LOG_DEBUG);
139 139
     }
140 140
 
141 141
     /**
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
      *
144 144
      * @param ModelCriteria $query
145 145
      */
146
-    private function addFilters(ModelCriteria &$query)
146
+    private function addFilters(ModelCriteria & $query)
147 147
     {
148 148
         if (count($this->query) > 0) {
149 149
             $tableMap = $this->getTableMap();
150 150
             foreach ($this->query as $field => $value) {
151 151
                 if (self::API_COMBO_FIELD === $field) {
152 152
                     ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
153
-                } elseif(!preg_match('/^__/', $field)) {
153
+                } elseif (!preg_match('/^__/', $field)) {
154 154
                     ApiHelper::addModelField($tableMap, $query, $field, $value);
155 155
                 }
156 156
             }
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
             list($page, $limit) = $this->extractPagination();
172 172
             if ($limit == -1) {
173 173
                 $this->list = $query->find($this->con);
174
-            } else {
174
+            }else {
175 175
                 $this->list = $query->paginate($page, $limit, $this->con);
176 176
             }
177
-        } catch (\Exception $e) {
177
+        }catch (\Exception $e) {
178 178
             Logger::log($e->getMessage(), LOG_ERR);
179 179
         }
180 180
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         $code = 200;
194 194
         list($return, $total, $pages) = $this->getList();
195 195
         $message = null;
196
-        if(!$total) {
196
+        if (!$total) {
197 197
             $message = _('No se han encontrado elementos para la búsqueda');
198 198
         }
199 199
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $pages = 1;
220 220
         $message = null;
221 221
         list($code, $return) = $this->getSingleResult($pk);
222
-        if($code !== 200) {
222
+        if ($code !== 200) {
223 223
             $message = _('No se ha encontrado el elemento solicitado');
224 224
         }
225 225
 
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
                 $status = 200;
249 249
                 $saved = TRUE;
250 250
                 $model = $this->model->toArray();
251
-            } else {
251
+            }else {
252 252
                 $message = _('No se ha podido modificar el modelo seleccionado');
253 253
             }
254
-        } catch (\Exception $e) {
255
-            $message = _('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage();
254
+        }catch (\Exception $e) {
255
+            $message = _('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage();
256 256
             Logger::log($e->getMessage(), LOG_ERR);
257 257
         }
258 258
 
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
                     $updated = TRUE;
287 287
                     $status = 200;
288 288
                     $model = $this->model->toArray();
289
-                } else {
289
+                }else {
290 290
                     $message = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
291 291
                 }
292
-            } catch (\Exception $e) {
292
+            }catch (\Exception $e) {
293 293
                 $message = $e->getMessage();
294 294
                 Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
295 295
             }
296
-        } else {
296
+        }else {
297 297
             $message = _('No se ha encontrado el modelo al que se hace referencia para actualizar');
298 298
         }
299 299
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                     $this->model->delete($this->con);
324 324
                     $deleted = TRUE;
325 325
                 }
326
-            } catch (\Exception $e) {
326
+            }catch (\Exception $e) {
327 327
                 $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados');
328 328
                 Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
329 329
             }
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
                 $total = $this->list->getNbResults();
358 358
                 $pages = $this->list->getLastPage();
359 359
             }
360
-        } catch (\Exception $e) {
361
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
360
+        }catch (\Exception $e) {
361
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
362 362
         }
363 363
 
364 364
         return array($return, $total, $pages);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         $return = array();
377 377
         if (NULL === $model || !method_exists($model, 'toArray')) {
378 378
             $code = 404;
379
-        } else {
379
+        }else {
380 380
             $return = $model->toArray();
381 381
         }
382 382
 
Please login to merge, or discard this patch.
src/base/types/Controller.php 2 patches
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -2,15 +2,11 @@
 block discarded – undo
2 2
 namespace PSFS\base\types;
3 3
 
4 4
 use PSFS\base\config\Config;
5
-use PSFS\base\exception\RouterException;
6
-use PSFS\base\Request;
7
-use PSFS\base\Router;
8 5
 use PSFS\base\Singleton;
9 6
 use PSFS\base\types\helpers\GeneratorHelper;
10 7
 use PSFS\base\types\helpers\Inspector;
11 8
 use PSFS\base\types\interfaces\ControllerInterface;
12 9
 use PSFS\base\types\traits\JsonTrait;
13
-use PSFS\base\types\traits\OutputTrait;
14 10
 use PSFS\base\types\traits\RouteTrait;
15 11
 
16 12
 /**
Please login to merge, or discard this 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/types/helpers/Inspector.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -14,6 +14,9 @@
 block discarded – undo
14 14
         ];
15 15
     }
16 16
 
17
+    /**
18
+     * @param string $name
19
+     */
17 20
     public static function stats($name = null) {
18 21
         self::$profiling[] = self::collect($name);
19 22
     }
Please login to merge, or discard this 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 = $_SERVER['REQUEST_TIME_FLOAT'] ?: 0;
43 43
         $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/types/traits/JsonTrait.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
      * @param mixed $response
19 19
      * @param int $statusCode
20 20
      *
21
-     * @return mixed JSON
21
+     * @return string|null JSON
22 22
      */
23 23
     public function json($response, $statusCode = 200)
24 24
     {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,19 +22,19 @@
 block discarded – undo
22 22
      */
23 23
     public function json($response, $statusCode = 200)
24 24
     {
25
-        if(Config::getParam('json.encodeUTF8', false)) {
25
+        if (Config::getParam('json.encodeUTF8', false)) {
26 26
             $response = I18nHelper::utf8Encode($response);
27 27
         }
28
-        if(Config::getParam('profiling.enable')) {
29
-            if(is_array($response)) {
28
+        if (Config::getParam('profiling.enable')) {
29
+            if (is_array($response)) {
30 30
                 $response['profiling'] = Inspector::getStats();
31
-            } elseif($response instanceof JsonResponse) {
31
+            } elseif ($response instanceof JsonResponse) {
32 32
                 $response = ProfilingJsonResponse::createFromPrevious($response, Inspector::getStats());
33 33
             }
34 34
         }
35 35
         $data = json_encode($response, JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING | JSON_NUMERIC_CHECK);
36
-        if(Config::getParam('angular.protection', false)) {
37
-            $data = ")]}',\n" . $data;
36
+        if (Config::getParam('angular.protection', false)) {
37
+            $data = ")]}',\n".$data;
38 38
         }
39 39
         $this->setStatus($statusCode);
40 40
         return $this->output($data, "application/json");
Please login to merge, or discard this patch.
src/bootstrap.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@
 block discarded – undo
3 3
 
4 4
 if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
5 5
 if (preg_match('/vendor/', SOURCE_DIR)) {
6
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
7
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
8
-} else {
9
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
10
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
6
+    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..');
7
+    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src');
8
+}else {
9
+    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..');
10
+    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules');
11 11
 }
12
-if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
13
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
14
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
15
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
16
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
12
+if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor');
13
+if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
14
+if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
15
+if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
16
+if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
17 17
 
18 18
 
19 19
 /**
Please login to merge, or discard this patch.
Braces   +31 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,19 +1,39 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace PSFS;
3 3
 
4
-if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
4
+if (!defined('SOURCE_DIR')) {
5
+    define('SOURCE_DIR', __DIR__);
6
+}
5 7
 if (preg_match('/vendor/', SOURCE_DIR)) {
6
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
7
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
8
-} else {
9
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
10
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
8
+    if (!defined('BASE_DIR')) {
9
+        define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
10
+    }
11
+    if (!defined('CORE_DIR')) {
12
+        define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
13
+    }
14
+    } else {
15
+    if (!defined('BASE_DIR')) {
16
+        define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
17
+    }
18
+    if (!defined('CORE_DIR')) {
19
+        define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
20
+    }
21
+    }
22
+if (!defined('VENDOR_DIR')) {
23
+    define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
24
+}
25
+if (!defined('LOG_DIR')) {
26
+    define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
27
+}
28
+if (!defined('CACHE_DIR')) {
29
+    define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
30
+}
31
+if (!defined('CONFIG_DIR')) {
32
+    define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
33
+}
34
+if (!defined('WEB_DIR')) {
35
+    define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
11 36
 }
12
-if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
13
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
14
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
15
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
16
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
17 37
 
18 38
 
19 39
 /**
Please login to merge, or discard this patch.
src/base/types/helpers/FileHelper.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class FileHelper {
10 10
     /**
11
-     * @param mixed $data
11
+     * @param string $data
12 12
      * @param string $path
13 13
      * @return int
14 14
      */
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     /**
20 20
      * @param string $path
21
-     * @return mixed|bool
21
+     * @return string|false
22 22
      */
23 23
     public static function readFile($path) {
24 24
         $data = false;
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     /**
54
-     * @param $path
55
-     * @return bool
54
+     * @param string $path
55
+     * @return boolean|null
56 56
      */
57 57
     public static function deleteDir($path) {
58 58
         (new Filesystem())->remove($path);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public static function readFile($path) {
24 24
         $data = false;
25
-        if(file_exists($path)) {
25
+        if (file_exists($path)) {
26 26
             $data = file_get_contents($path);
27 27
         }
28 28
         return $data;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * @return string
36 36
      */
37 37
     public static function generateHashFilename($verb, $slug, array $query = []) {
38
-        return sha1(strtolower($verb) . " " . $slug . " " . strtolower(http_build_query($query)));
38
+        return sha1(strtolower($verb)." ".$slug." ".strtolower(http_build_query($query)));
39 39
     }
40 40
 
41 41
     /**
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
     public static function generateCachePath(array $action, array $query = []) {
47 47
         $class = GeneratorHelper::extractClassFromNamespace($action['class']);
48 48
         $filename = self::generateHashFilename($action["http"], $action["slug"], $query);
49
-        $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2);
50
-        return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR;
49
+        $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2);
50
+        return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR;
51 51
     }
52 52
 
53 53
     /**
Please login to merge, or discard this patch.
src/base/types/helpers/I18nHelper.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
     /**
20 20
      * @param string $default
21
-     * @return array|mixed|string
21
+     * @return string
22 22
      */
23 23
     private static function extractLocale($default = null)
24 24
     {
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
                 list($BrowserLocales[$i]) = explode(";", $BrowserLocales[$i]); //trick for "en;q=0.8"
30 30
             }
31 31
             $locale = array_shift($BrowserLocales);
32
-        } else {
32
+        }else {
33 33
             $locale = strtolower($locale);
34 34
         }
35 35
         if (false !== strpos($locale, '_')) {
36 36
             $locale = explode('_', $locale);
37 37
             if ($locale[0] == 'en') {
38
-                $locale = $locale[0] . '_GB';
39
-            } else {
40
-                $locale = $locale[0] . '_' . strtoupper($locale[1]);
38
+                $locale = $locale[0].'_GB';
39
+            }else {
40
+                $locale = $locale[0].'_'.strtoupper($locale[1]);
41 41
             }
42
-        } else {
42
+        }else {
43 43
             if (strtolower($locale) === 'en') {
44 44
                 $locale = 'en_GB';
45
-            } else {
46
-                $locale = $locale . '_' . strtoupper($locale);
45
+            }else {
46
+                $locale = $locale.'_'.strtoupper($locale);
47 47
             }
48 48
         }
49 49
         if (!in_array($locale, self::$langs)) {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $translations = array();
65 65
         if (file_exists($absoluteTranslationFileName)) {
66 66
             @include($absoluteTranslationFileName);
67
-        } else {
67
+        }else {
68 68
             Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
69 69
         }
70 70
 
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
     public static function setLocale()
78 78
     {
79 79
         $locale = self::extractLocale('es_ES');
80
-        Logger::log('Set locale to project [' . $locale . ']');
80
+        Logger::log('Set locale to project ['.$locale.']');
81 81
         // Load translations
82
-        putenv("LC_ALL=" . $locale);
82
+        putenv("LC_ALL=".$locale);
83 83
         setlocale(LC_ALL, $locale);
84 84
         // Load the locale path
85
-        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
86
-        Logger::log('Set locale dir ' . $locale_path);
85
+        $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
86
+        Logger::log('Set locale dir '.$locale_path);
87 87
         GeneratorHelper::createDir($locale_path);
88 88
         bindtextdomain('translations', $locale_path);
89 89
         textdomain('translations');
Please login to merge, or discard this patch.
src/base/types/traits/Api/MutationTrait.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -65,21 +65,21 @@  discard block
 block discarded – undo
65 65
         if (count($pks) == 1) {
66 66
             $pks = array_keys($pks);
67 67
             return [
68
-                $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD
68
+                $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD
69 69
             ];
70 70
         } elseif (count($pks) > 1) {
71 71
             $apiPks = [];
72 72
             $principal = '';
73 73
             $sep = 'CONCAT(';
74 74
             foreach ($pks as $pk) {
75
-                $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName();
76
-                $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName();
77
-                $sep = ', "' . Api::API_PK_SEPARATOR . '", ';
75
+                $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName();
76
+                $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName();
77
+                $sep = ', "'.Api::API_PK_SEPARATOR.'", ';
78 78
             }
79 79
             $principal .= ')';
80 80
             $apiPks[$principal] = Api::API_MODEL_KEY_FIELD;
81 81
             return $apiPks;
82
-        } else {
82
+        }else {
83 83
             throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta'));
84 84
         }
85 85
     }
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
         $pks = '';
103 103
         $sep = '';
104 104
         foreach ($tableMap->getPrimaryKeys() as $pk) {
105
-            $pks .= $sep . $pk->getFullyQualifiedName();
105
+            $pks .= $sep.$pk->getFullyQualifiedName();
106 106
             $sep = ', "|", ';
107 107
         }
108
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD;
108
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD;
109 109
     }
110 110
 
111 111
     /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             }
128 128
             if (null !== $column) {
129 129
                 $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD;
130
-            } else {
130
+            }else {
131 131
                 $this->addClassListName($tableMap);
132 132
             }
133 133
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @param ModelCriteria $query
140 140
      * @param string $action
141 141
      */
142
-    private function addExtraColumns(ModelCriteria &$query, $action)
142
+    private function addExtraColumns(ModelCriteria & $query, $action)
143 143
     {
144 144
         if (Api::API_ACTION_LIST === $action) {
145 145
             $this->addDefaultListField();
@@ -173,21 +173,21 @@  discard block
 block discarded – undo
173 173
     /**
174 174
      * @param ModelCriteria $query
175 175
      */
176
-    protected function checkI18n(ModelCriteria &$query)
176
+    protected function checkI18n(ModelCriteria & $query)
177 177
     {
178 178
         $this->extractApiLang();
179 179
         $model = $this->getModelNamespace();
180
-        $modelI18n = $model . 'I18n';
180
+        $modelI18n = $model.'I18n';
181 181
         if (method_exists($query, 'useI18nQuery')) {
182 182
             $query->useI18nQuery($this->lang);
183
-            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n) . 'TableMap';
183
+            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n).'TableMap';
184 184
             /** @var TableMap $modelI18nTableMap */
185 185
             $modelI18nTableMap = $modelI18nTableMapClass::getTableMap();
186
-            foreach($modelI18nTableMap->getColumns() as $columnMap) {
187
-                if(!$columnMap->isPrimaryKey()) {
188
-                    $query->withColumn($modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName(), $columnMap->getPhpName());
189
-                } elseif(!$columnMap->isForeignKey()) {
190
-                    $query->withColumn('IFNULL(' . $modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName() . ', "'.$this->lang.'")', $columnMap->getPhpName());
186
+            foreach ($modelI18nTableMap->getColumns() as $columnMap) {
187
+                if (!$columnMap->isPrimaryKey()) {
188
+                    $query->withColumn($modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName(), $columnMap->getPhpName());
189
+                } elseif (!$columnMap->isForeignKey()) {
190
+                    $query->withColumn('IFNULL('.$modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName().', "'.$this->lang.'")', $columnMap->getPhpName());
191 191
                 }
192 192
             }
193 193
         }
@@ -197,23 +197,23 @@  discard block
 block discarded – undo
197 197
      * @param ActiveRecordInterface $model
198 198
      * @param array $data
199 199
      */
200
-    protected function hydrateModelFromRequest(ActiveRecordInterface &$model, array $data = []) {
200
+    protected function hydrateModelFromRequest(ActiveRecordInterface & $model, array $data = []) {
201 201
         $model->fromArray($data);
202 202
         $tableMap = $this->getTableMap();
203 203
         try {
204
-            $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n');
205
-            if(null !== $relateI18n) {
204
+            $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n');
205
+            if (null !== $relateI18n) {
206 206
                 $i18NTableMap = $relateI18n->getLocalTable();
207
-                foreach($i18NTableMap->getColumns() as $columnMap) {
208
-                    $method = 'set' . $columnMap->getPhpName();
209
-                    if(!($columnMap->isPrimaryKey() && $columnMap->isForeignKey())
207
+                foreach ($i18NTableMap->getColumns() as $columnMap) {
208
+                    $method = 'set'.$columnMap->getPhpName();
209
+                    if (!($columnMap->isPrimaryKey() && $columnMap->isForeignKey())
210 210
                         &&array_key_exists($columnMap->getPhpName(), $data)
211 211
                         && method_exists($model, $method)) {
212 212
                         $model->$method($data[$columnMap->getPhpName()]);
213 213
                     }
214 214
                 }
215 215
             }
216
-        } catch(\Exception $e) {
216
+        }catch (\Exception $e) {
217 217
             Logger::log($e->getMessage(), LOG_WARNING);
218 218
         }
219 219
     }
Please login to merge, or discard this patch.