Passed
Push — master ( 6df67e...d71c1b )
by Fran
03:24
created
src/base/Security.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             session_start();
74 74
         }
75 75
         // Fix for phpunits
76
-        if(!isset($_SESSION)) {
76
+        if (!isset($_SESSION)) {
77 77
             $_SESSION = [];
78 78
         }
79 79
     }
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
     {
134 134
         $saved = true;
135 135
         try {
136
-            $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
137
-            $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
136
+            $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
137
+            $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
138 138
             $admins[$user['username']]['profile'] = $user['profile'];
139 139
 
140
-            Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
141
-        } catch(\Exception $e) {
140
+            Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
141
+        }catch (\Exception $e) {
142 142
             Logger::log($e->getMessage(), LOG_ERR);
143 143
             $saved = false;
144 144
         }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      */
176 176
     public function getAdmins()
177 177
     {
178
-        return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true);
178
+        return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true);
179 179
     }
180 180
 
181 181
     /**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                 }
204 204
                 if (!empty($user) && !empty($admins[$user])) {
205 205
                     $auth = $admins[$user]['hash'];
206
-                    $this->authorized = ($auth == sha1($user . $pass));
206
+                    $this->authorized = ($auth == sha1($user.$pass));
207 207
                     if ($this->authorized) {
208 208
                         $this->admin = array(
209 209
                             'alias' => $user,
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                         );
212 212
                         $this->setSessionKey(self::ADMIN_ID_TOKEN, serialize($this->admin));
213 213
                     }
214
-                } else {
214
+                }else {
215 215
                     $this->admin = null;
216 216
                     $this->setSessionKey(self::ADMIN_ID_TOKEN, null);
217 217
                 }
Please login to merge, or discard this patch.
src/base/types/Api.php 1 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/traits/Api/ApiTrait.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      *
94 94
      * @param ModelCriteria $query
95 95
      */
96
-    protected function joinTables(ModelCriteria &$query)
96
+    protected function joinTables(ModelCriteria & $query)
97 97
     {
98 98
         //TODO for specific implementations
99 99
     }
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
      */
107 107
     protected function findPk(ModelCriteria $query, $pk) {
108 108
         $pks = explode(Api::API_PK_SEPARATOR, urldecode($pk));
109
-        if(count($pks) == 1 && !empty($pks[0])) {
109
+        if (count($pks) == 1 && !empty($pks[0])) {
110 110
             $model = $query->findPk($pks[0], $this->con);
111
-        } else {
111
+        }else {
112 112
             $i = 0;
113
-            foreach($this->getPkDbName() as $key => $phpName) {
113
+            foreach ($this->getPkDbName() as $key => $phpName) {
114 114
                 try {
115 115
                     $query->filterBy($phpName, $pks[$i]);
116 116
                     $i++;
117
-                    if($i >= count($pks)) break;
118
-                } catch(\Exception $e) {
117
+                    if ($i >= count($pks)) break;
118
+                }catch (\Exception $e) {
119 119
                     Logger::log($e->getMessage(), LOG_DEBUG);
120 120
                 }
121 121
             }
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
         try {
146 146
             $query = $this->prepareQuery();
147 147
             $this->model = $this->findPk($query, $pk);
148
-        } catch (\Exception $e) {
149
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
148
+        }catch (\Exception $e) {
149
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
150 150
         }
151 151
     }
152 152
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * @param ModelCriteria $query
169 169
      */
170
-    protected function checkReturnFields(ModelCriteria &$query)
170
+    protected function checkReturnFields(ModelCriteria & $query)
171 171
     {
172 172
         $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD);
173 173
         if (null !== $returnFields) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,9 @@
 block discarded – undo
114 114
                 try {
115 115
                     $query->filterBy($phpName, $pks[$i]);
116 116
                     $i++;
117
-                    if($i >= count($pks)) break;
117
+                    if($i >= count($pks)) {
118
+                        break;
119
+                    }
118 120
                 } catch(\Exception $e) {
119 121
                     Logger::log($e->getMessage(), LOG_DEBUG);
120 122
                 }
Please login to merge, or discard this patch.