Passed
Push — master ( 6df67e...d71c1b )
by Fran
03:24
created
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
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
     public function init()
73 73
     {
74 74
         parent::init();
75
-        Logger::log(get_called_class() . ' init', LOG_DEBUG);
75
+        Logger::log(get_called_class().' init', LOG_DEBUG);
76 76
         $this->domain = $this->getDomain();
77 77
         $this->hydrateRequestData();
78 78
         $this->hydrateOrders();
79 79
         $this->createConnection($this->getTableMap());
80 80
         $this->setLoaded(true);
81
-        Logger::log(get_called_class() . ' loaded', LOG_DEBUG);
81
+        Logger::log(get_called_class().' loaded', LOG_DEBUG);
82 82
     }
83 83
 
84 84
     /**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     private function hydrateOrders()
88 88
     {
89 89
         if (count($this->query)) {
90
-            Logger::log(get_called_class() . ' gathering query string', LOG_DEBUG);
90
+            Logger::log(get_called_class().' gathering query string', LOG_DEBUG);
91 91
             foreach ($this->query as $key => $value) {
92 92
                 if ($key === self::API_ORDER_FIELD) {
93 93
                     foreach ($value as $field => $direction) {
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
      */
105 105
     protected function extractPagination()
106 106
     {
107
-        Logger::log(get_called_class() . ' extract pagination start', LOG_DEBUG);
107
+        Logger::log(get_called_class().' extract pagination start', LOG_DEBUG);
108 108
         $page = (array_key_exists(self::API_PAGE_FIELD, $this->query)) ? $this->query[self::API_PAGE_FIELD] : 1;
109 109
         $limit = (array_key_exists(self::API_LIMIT_FIELD, $this->query)) ? $this->query[self::API_LIMIT_FIELD] : 100;
110
-        Logger::log(get_called_class() . ' extract pagination end', LOG_DEBUG);
110
+        Logger::log(get_called_class().' extract pagination end', LOG_DEBUG);
111 111
         return array($page, $limit);
112 112
     }
113 113
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @param ModelCriteria $query
118 118
      */
119
-    private function addOrders(ModelCriteria &$query)
119
+    private function addOrders(ModelCriteria & $query)
120 120
     {
121
-        Logger::log(get_called_class() . ' extract orders start ', LOG_DEBUG);
121
+        Logger::log(get_called_class().' extract orders start ', LOG_DEBUG);
122 122
         $orderAdded = FALSE;
123 123
         $tableMap = $this->getTableMap();
124 124
         foreach ($this->order->getOrders() as $field => $direction) {
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
                 $orderAdded = TRUE;
127 127
                 if ($direction === Order::ASC) {
128 128
                     $query->addAscendingOrderByColumn($column->getPhpName());
129
-                } else {
129
+                }else {
130 130
                     $query->addDescendingOrderByColumn($column->getPhpName());
131 131
                 }
132 132
             }
133 133
         }
134 134
         if (!$orderAdded) {
135
-            foreach($this->getPkDbName() as $pk => $phpName) {
135
+            foreach ($this->getPkDbName() as $pk => $phpName) {
136 136
                 $query->addAscendingOrderByColumn($pk);
137 137
             }
138 138
         }
139
-        Logger::log(get_called_class() . ' extract orders end', LOG_DEBUG);
139
+        Logger::log(get_called_class().' extract orders end', LOG_DEBUG);
140 140
     }
141 141
 
142 142
     /**
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
      *
145 145
      * @param ModelCriteria $query
146 146
      */
147
-    protected function addFilters(ModelCriteria &$query)
147
+    protected function addFilters(ModelCriteria & $query)
148 148
     {
149 149
         if (count($this->query) > 0) {
150 150
             $tableMap = $this->getTableMap();
151 151
             foreach ($this->query as $field => $value) {
152 152
                 if (self::API_COMBO_FIELD === $field) {
153 153
                     ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
154
-                } elseif(!preg_match('/^__/', $field)) {
154
+                } elseif (!preg_match('/^__/', $field)) {
155 155
                     ApiHelper::addModelField($tableMap, $query, $field, $value);
156 156
                 }
157 157
             }
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
             list($page, $limit) = $this->extractPagination();
173 173
             if ($limit == -1) {
174 174
                 $this->list = $query->find($this->con);
175
-            } else {
175
+            }else {
176 176
                 $this->list = $query->paginate($page, $limit, $this->con);
177 177
             }
178
-        } catch (\Exception $e) {
178
+        }catch (\Exception $e) {
179 179
             Logger::log($e->getMessage(), LOG_ERR);
180 180
         }
181 181
     }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         $code = 200;
195 195
         list($return, $total, $pages) = $this->getList();
196 196
         $message = null;
197
-        if(!$total) {
197
+        if (!$total) {
198 198
             $message = _('No se han encontrado elementos para la búsqueda');
199 199
         }
200 200
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
         $pages = 1;
221 221
         $message = null;
222 222
         list($code, $return) = $this->getSingleResult($pk);
223
-        if($code !== 200) {
223
+        if ($code !== 200) {
224 224
             $message = _('No se ha encontrado el elemento solicitado');
225 225
         }
226 226
 
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
                 $status = 200;
250 250
                 $saved = TRUE;
251 251
                 $model = $this->model->toArray();
252
-            } else {
252
+            }else {
253 253
                 $message = _('No se ha podido modificar el modelo seleccionado');
254 254
             }
255
-        } catch (\Exception $e) {
256
-            $message = _('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage();
255
+        }catch (\Exception $e) {
256
+            $message = _('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage();
257 257
             Logger::log($e->getMessage(), LOG_ERR);
258 258
         }
259 259
 
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
                     $updated = TRUE;
288 288
                     $status = 200;
289 289
                     $model = $this->model->toArray();
290
-                } else {
290
+                }else {
291 291
                     $message = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
292 292
                 }
293
-            } catch (\Exception $e) {
293
+            }catch (\Exception $e) {
294 294
                 $message = $e->getMessage();
295 295
                 Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
296 296
             }
297
-        } else {
297
+        }else {
298 298
             $message = _('No se ha encontrado el modelo al que se hace referencia para actualizar');
299 299
         }
300 300
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
                     $this->model->delete($this->con);
325 325
                     $deleted = TRUE;
326 326
                 }
327
-            } catch (\Exception $e) {
327
+            }catch (\Exception $e) {
328 328
                 $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados');
329 329
                 Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
330 330
             }
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
                 $total = $this->list->getNbResults();
359 359
                 $pages = $this->list->getLastPage();
360 360
             }
361
-        } catch (\Exception $e) {
362
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
361
+        }catch (\Exception $e) {
362
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
363 363
         }
364 364
 
365 365
         return array($return, $total, $pages);
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
         $return = array();
378 378
         if (NULL === $model || !method_exists($model, 'toArray')) {
379 379
             $code = 404;
380
-        } else {
380
+        }else {
381 381
             $return = $model->toArray();
382 382
         }
383 383
 
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.
src/base/Template.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $dump = '';
114 114
         try {
115 115
             $dump = $this->tpl->render($tpl, $vars);
116
-        } catch (\Exception $e) {
116
+        }catch (\Exception $e) {
117 117
             Logger::log($e->getMessage(), LOG_ERR);
118 118
         }
119 119
         return $dump;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     public function regenerateTemplates()
141 141
     {
142 142
         $this->generateTemplatesCache();
143
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true);
143
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true);
144 144
         $translations = [];
145 145
         if (is_array($domains)) {
146 146
             $translations = $this->parsePathTranslations($domains);
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
             // force compilation
163 163
             if ($file->isFile()) {
164 164
                 try {
165
-                    $this->tpl->load(str_replace($tplDir . '/', '', $file));
166
-                } catch (\Exception $e) {
165
+                    $this->tpl->load(str_replace($tplDir.'/', '', $file));
166
+                }catch (\Exception $e) {
167 167
                     Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]);
168 168
                 }
169 169
             }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION,
225 225
             'getQuery' => TemplateFunctions::GET_QUERY_FUNCTION,
226 226
         ];
227
-        foreach($functions as $name => $function) {
227
+        foreach ($functions as $name => $function) {
228 228
             $this->addTemplateFunction($name, $function);
229 229
         }
230 230
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      */
244 244
     private function loadDomains()
245 245
     {
246
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true);
246
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true);
247 247
         if (null !== $domains) {
248 248
             foreach ($domains as $domain => $paths) {
249 249
                 $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain));
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     {
259 259
         $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath());
260 260
         $this->tpl = new \Twig_Environment($loader, array(
261
-            'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig',
261
+            'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig',
262 262
             'debug' => (bool)$this->debug,
263 263
             'auto_reload' => Config::getParam('twig.autoreload', TRUE),
264 264
         ));
Please login to merge, or discard this patch.