Passed
Push — master ( 2ff097...780918 )
by Fran
05:07
created
src/base/Service.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     protected $isMultipart = false;
71 71
 
72 72
     private function closeConnection() {
73
-        if(null !== $this->con) {
73
+        if (null !== $this->con) {
74 74
             curl_close($this->con);
75 75
         }
76 76
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      */
234 234
     public function setIsJson($isJson = true) {
235 235
         $this->isJson = $isJson;
236
-        if($isJson) {
236
+        if ($isJson) {
237 237
             $this->setIsMultipart(false);
238 238
         }
239 239
     }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     public function setIsMultipart($isMultipart = true) {
253 253
         $this->isMultipart = $isMultipart;
254
-        if($isMultipart) {
254
+        if ($isMultipart) {
255 255
             $this->setIsJson(false);
256 256
         }
257 257
     }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         $this->url = NULL;
272 272
         $this->params = array();
273 273
         $this->headers = array();
274
-        Logger::log('Context service for ' . static::class . ' cleared!');
274
+        Logger::log('Context service for '.static::class.' cleared!');
275 275
         $this->closeConnection();
276 276
     }
277 277
 
@@ -314,18 +314,18 @@  discard block
 block discarded – undo
314 314
     }
315 315
 
316 316
     protected function applyOptions() {
317
-        if(count($this->options)) {
317
+        if (count($this->options)) {
318 318
             curl_setopt_array($this->con, $this->options);
319 319
         }
320 320
     }
321 321
 
322 322
     protected function applyHeaders() {
323 323
         $headers = [];
324
-        foreach($this->headers as $key => $value) {
325
-            $headers[] = $key . ': ' . $value;
324
+        foreach ($this->headers as $key => $value) {
325
+            $headers[] = $key.': '.$value;
326 326
         }
327 327
         $headers[self::PSFS_TRACK_HEADER] = Logger::getUid();
328
-        if(count($headers)) {
328
+        if (count($headers)) {
329 329
             curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers);
330 330
         }
331 331
     }
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
      * @return int
335 335
      */
336 336
     private function parseServiceType() {
337
-        if($this->getIsJson()) {
337
+        if ($this->getIsJson()) {
338 338
             return ServiceHelper::TYPE_JSON;
339 339
         }
340
-        if($this->getIsMultipart()) {
340
+        if ($this->getIsMultipart()) {
341 341
             return ServiceHelper::TYPE_MULTIPART;
342 342
         }
343 343
         return ServiceHelper::TYPE_HTTP;
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
             case Request::VERB_GET:
351 351
             default:
352 352
                 $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_GET);
353
-                if(!empty($this->params)) {
353
+                if (!empty($this->params)) {
354 354
                     $sep = false === strpos($this->getUrl(), '?') ? '?' : '';
355
-                    $this->url = $this->url . $sep . http_build_query($this->params);
355
+                    $this->url = $this->url.$sep.http_build_query($this->params);
356 356
                 }
357 357
                 break;
358 358
             case Request::VERB_POST:
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
         $this->applyOptions();
385 385
         $this->applyHeaders();
386 386
         $verbose = null;
387
-        if('debug' === Config::getParam('log.level')) {
387
+        if ('debug' === Config::getParam('log.level')) {
388 388
             curl_setopt($this->con, CURLOPT_VERBOSE, true);
389 389
             $verbose = fopen('php://temp', 'wb+');
390 390
             curl_setopt($this->con, CURLOPT_STDERR, $verbose);
391 391
         }
392 392
         $result = curl_exec($this->con);
393 393
         $this->result = $this->isJson ? json_decode($result, true) : $result;
394
-        if('debug' === Config::getParam('log.level')) {
394
+        if ('debug' === Config::getParam('log.level')) {
395 395
             rewind($verbose);
396 396
             $verboseLog = stream_get_contents($verbose);
397 397
             Logger::log($verboseLog, LOG_DEBUG, [
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             ]);
402 402
             $this->info['verbose'] = $verboseLog;
403 403
         }
404
-        Logger::log($this->url . ' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]);
404
+        Logger::log($this->url.' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]);
405 405
         $this->info = array_merge($this->info, curl_getinfo($this->con));
406 406
     }
407 407
 
Please login to merge, or discard this patch.
src/base/types/helpers/SlackHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
             'attachments' => [
30 30
                 [
31 31
                     "author_name" => $request->getRootUrl(true),
32
-                    "text" => $file . (strlen($line) ? ' [' . $line . ']' : ''),
32
+                    "text" => $file.(strlen($line) ? ' ['.$line.']' : ''),
33 33
                     "color" => Config::getParam('debug', true) ? 'warning' : "danger",
34 34
                     "title" => $message,
35 35
                     'fallback' => 'PSFS Error notifier',
Please login to merge, or discard this patch.
src/base/types/traits/Api/MutationTrait.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         if (count($pks) === 1) {
81 81
             $pks = array_keys($pks);
82 82
             return [
83
-                $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD
83
+                $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD
84 84
             ];
85 85
         }
86 86
         if (count($pks) > 1) {
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
             $principal = '';
89 89
             $sep = 'CONCAT(';
90 90
             foreach ($pks as $pk) {
91
-                $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName();
92
-                $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName();
93
-                $sep = ', "' . Api::API_PK_SEPARATOR . '", ';
91
+                $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName();
92
+                $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName();
93
+                $sep = ', "'.Api::API_PK_SEPARATOR.'", ';
94 94
             }
95 95
             $principal .= ')';
96 96
             $apiPks[$principal] = Api::API_MODEL_KEY_FIELD;
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
         $pks = '';
118 118
         $sep = '';
119 119
         foreach ($tableMap->getPrimaryKeys() as $pk) {
120
-            $pks .= $sep . $pk->getFullyQualifiedName();
120
+            $pks .= $sep.$pk->getFullyQualifiedName();
121 121
             $sep = ', "|", ';
122 122
         }
123
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD;
123
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD;
124 124
     }
125 125
 
126 126
     /**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             }
143 143
             if (null !== $column) {
144 144
                 $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD;
145
-            } else {
145
+            }else {
146 146
                 $this->addClassListName($tableMap);
147 147
             }
148 148
         }
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
             $this->addPkToList();
162 162
         }
163 163
         if (!empty($this->extraColumns)) {
164
-            if(Config::getParam('api.extrafields.compat', true)) {
164
+            if (Config::getParam('api.extrafields.compat', true)) {
165 165
                 $fields = array_values($this->extraColumns);
166
-            } else {
166
+            }else {
167 167
                 $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD);
168 168
                 $fields = explode(',', $returnFields ?: '');
169 169
                 $fields[] = self::API_MODEL_KEY_FIELD;
170 170
             }
171 171
             foreach ($this->extraColumns as $expression => $columnName) {
172
-                if(empty($fields) || in_array($columnName, $fields)) {
172
+                if (empty($fields) || in_array($columnName, $fields)) {
173 173
                     $query->withColumn($expression, $columnName);
174 174
                 }
175 175
             }
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
     {
202 202
         $this->extractApiLang();
203 203
         $model = $this->getModelNamespace();
204
-        $modelI18n = $model . 'I18n';
204
+        $modelI18n = $model.'I18n';
205 205
         if (method_exists($query, 'useI18nQuery')) {
206 206
             $query->useI18nQuery($this->lang);
207
-            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n) . 'TableMap';
207
+            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n).'TableMap';
208 208
             /** @var TableMap $modelI18nTableMap */
209 209
             $modelI18nTableMap = $modelI18nTableMapClass::getTableMap();
210
-            foreach($modelI18nTableMap->getColumns() as $columnMap) {
211
-                if(!$columnMap->isPrimaryKey()) {
210
+            foreach ($modelI18nTableMap->getColumns() as $columnMap) {
211
+                if (!$columnMap->isPrimaryKey()) {
212 212
                     $query->withColumn($columnMap->getFullyQualifiedName(), ApiHelper::getColumnMapName($columnMap));
213
-                } elseif(!$columnMap->isForeignKey()) {
214
-                    $query->withColumn('IFNULL(' . $columnMap->getFullyQualifiedName() . ', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap));
213
+                } elseif (!$columnMap->isForeignKey()) {
214
+                    $query->withColumn('IFNULL('.$columnMap->getFullyQualifiedName().', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap));
215 215
                 }
216 216
             }
217 217
         }
@@ -225,22 +225,22 @@  discard block
 block discarded – undo
225 225
         $model->fromArray($data, ApiHelper::getFieldTypes());
226 226
         $tableMap = $this->getTableMap();
227 227
         try {
228
-            if($tableMap->hasRelation($tableMap->getPhpName() . 'I18n'))
228
+            if ($tableMap->hasRelation($tableMap->getPhpName().'I18n'))
229 229
             {
230
-                $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n');
230
+                $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n');
231 231
                 $i18NTableMap = $relateI18n->getLocalTable();
232 232
                 $model->setLocale($this->lang);
233
-                foreach($i18NTableMap->getColumns() as $columnMap) {
234
-                    $method = 'set' . $columnMap->getPhpName();
233
+                foreach ($i18NTableMap->getColumns() as $columnMap) {
234
+                    $method = 'set'.$columnMap->getPhpName();
235 235
                     $dtoColumnName = ApiHelper::getColumnMapName($columnMap);
236
-                    if(array_key_exists($dtoColumnName, $data)
236
+                    if (array_key_exists($dtoColumnName, $data)
237 237
                         && method_exists($model, $method)
238 238
                         && !($columnMap->isPrimaryKey() && $columnMap->isForeignKey())) {
239 239
                         $model->$method($data[$dtoColumnName]);
240 240
                     }
241 241
                 }
242 242
             }
243
-        } catch(\Exception $e) {
243
+        }catch (\Exception $e) {
244 244
             Logger::log($e->getMessage(), LOG_DEBUG);
245 245
         }
246 246
     }
Please login to merge, or discard this patch.
src/base/types/Api.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
     public function init()
82 82
     {
83 83
         parent::init();
84
-        Logger::log(static::class . ' init', LOG_DEBUG);
84
+        Logger::log(static::class.' init', LOG_DEBUG);
85 85
         $this->domain = $this->getDomain();
86 86
         $this->hydrateRequestData();
87 87
         $this->hydrateOrders();
88
-        if($this instanceof CustomApi === false) {
88
+        if ($this instanceof CustomApi === false) {
89 89
             $this->createConnection($this->getTableMap());
90 90
         }
91 91
         $this->checkFieldType();
92 92
         $this->setLoaded(true);
93
-        Logger::log(static::class . ' loaded', LOG_DEBUG);
93
+        Logger::log(static::class.' loaded', LOG_DEBUG);
94 94
     }
95 95
 
96 96
     private function checkActions($method) {
97
-        switch($method) {
97
+        switch ($method) {
98 98
             default:
99 99
             case 'modelList': $this->action = self::API_ACTION_LIST; break;
100 100
             case 'get': $this->action = self::API_ACTION_GET; break;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     protected function hydrateOrders()
112 112
     {
113 113
         if (count($this->query)) {
114
-            Logger::log(static::class . ' gathering query string', LOG_DEBUG);
114
+            Logger::log(static::class.' gathering query string', LOG_DEBUG);
115 115
             foreach ($this->query as $key => $value) {
116 116
                 if ($key === self::API_ORDER_FIELD && is_array($value)) {
117 117
                     foreach ($value as $field => $direction) {
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
      */
129 129
     protected function extractPagination()
130 130
     {
131
-        Logger::log(static::class . ' extract pagination start', LOG_DEBUG);
131
+        Logger::log(static::class.' extract pagination start', LOG_DEBUG);
132 132
         $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1;
133 133
         $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100;
134
-        Logger::log(static::class . ' extract pagination end', LOG_DEBUG);
134
+        Logger::log(static::class.' extract pagination end', LOG_DEBUG);
135 135
         return array($page, (int)$limit);
136 136
     }
137 137
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     private function addOrders(ModelCriteria &$query)
144 144
     {
145
-        Logger::log(static::class . ' extract orders start ', LOG_DEBUG);
145
+        Logger::log(static::class.' extract orders start ', LOG_DEBUG);
146 146
         $orderAdded = FALSE;
147 147
         $tableMap = $this->getTableMap();
148 148
         foreach ($this->order->getOrders() as $field => $direction) {
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
                 $orderAdded = TRUE;
151 151
                 if ($direction === Order::ASC) {
152 152
                     $query->addAscendingOrderByColumn($column->getPhpName());
153
-                } else {
153
+                }else {
154 154
                     $query->addDescendingOrderByColumn($column->getPhpName());
155 155
                 }
156 156
             }
157 157
         }
158 158
         if (!$orderAdded) {
159 159
             $pks = $this->getPkDbName();
160
-            foreach(array_keys($pks) as $key) {
160
+            foreach (array_keys($pks) as $key) {
161 161
                 $query->addAscendingOrderByColumn($key);
162 162
             }
163 163
         }
164
-        Logger::log(static::class . ' extract orders end', LOG_DEBUG);
164
+        Logger::log(static::class.' extract orders end', LOG_DEBUG);
165 165
     }
166 166
 
167 167
     /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             foreach ($this->query as $field => $value) {
177 177
                 if (self::API_COMBO_FIELD === $field) {
178 178
                     ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
179
-                } elseif(!preg_match('/^__/', $field)) {
179
+                } elseif (!preg_match('/^__/', $field)) {
180 180
                     ApiHelper::addModelField($tableMap, $query, $field, $value);
181 181
                 }
182 182
             }
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
             list($page, $limit) = $this->extractPagination();
198 198
             if ($limit === -1) {
199 199
                 $this->list = $query->find($this->con);
200
-            } else {
200
+            }else {
201 201
                 $this->list = $query->paginate($page, $limit, $this->con);
202 202
             }
203
-        } catch (\Exception $e) {
203
+        }catch (\Exception $e) {
204 204
             Logger::log($e->getMessage(), LOG_ERR);
205 205
         }
206 206
     }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $code = 200;
220 220
         list($return, $total, $pages) = $this->getList();
221 221
         $message = null;
222
-        if(!$total) {
222
+        if (!$total) {
223 223
             $message = t('No se han encontrado elementos para la búsqueda');
224 224
         }
225 225
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         $pages = 1;
246 246
         $message = null;
247 247
         list($code, $return) = $this->getSingleResult($pk);
248
-        if($code !== 200) {
248
+        if ($code !== 200) {
249 249
             $message = t('No se ha encontrado el elemento solicitado');
250 250
         }
251 251
 
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
                 $status = 200;
275 275
                 $saved = TRUE;
276 276
                 $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
277
-            } else {
277
+            }else {
278 278
                 $message = t('No se ha podido guardar el modelo seleccionado');
279 279
             }
280
-        } catch (\Exception $e) {
281
-            $message = t('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage();
280
+        }catch (\Exception $e) {
281
+            $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage();
282 282
             $context = [];
283
-            if(null !== $e->getPrevious()) {
283
+            if (null !== $e->getPrevious()) {
284 284
                 $context[] = $e->getPrevious()->getMessage();
285 285
             }
286 286
             Logger::log($e->getMessage(), LOG_CRIT, $context);
@@ -316,18 +316,18 @@  discard block
 block discarded – undo
316 316
                     $updated = TRUE;
317 317
                     $status = 200;
318 318
                     $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
319
-                } else {
319
+                }else {
320 320
                     $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
321 321
                 }
322
-            } catch (\Exception $e) {
322
+            }catch (\Exception $e) {
323 323
                 $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
324 324
                 $context = [];
325
-                if(null !== $e->getPrevious()) {
325
+                if (null !== $e->getPrevious()) {
326 326
                     $context[] = $e->getPrevious()->getMessage();
327 327
                 }
328 328
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
329 329
             }
330
-        } else {
330
+        }else {
331 331
             $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar');
332 332
         }
333 333
 
@@ -355,15 +355,15 @@  discard block
 block discarded – undo
355 355
                 $this->con->beginTransaction();
356 356
                 $this->hydrateModel($pk);
357 357
                 if (NULL !== $this->model) {
358
-                    if(method_exists('clearAllReferences', $this->model)) {
358
+                    if (method_exists('clearAllReferences', $this->model)) {
359 359
                         $this->model->clearAllReferences(true);
360 360
                     }
361 361
                     $this->model->delete($this->con);
362 362
                     $deleted = TRUE;
363 363
                 }
364
-            } catch (\Exception $e) {
364
+            }catch (\Exception $e) {
365 365
                 $context = [];
366
-                if(null !== $e->getPrevious()) {
366
+                if (null !== $e->getPrevious()) {
367 367
                     $context[] = $e->getPrevious()->getMessage();
368 368
                 }
369 369
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             $this->saveBulk();
393 393
             $saved = true;
394 394
             $status = 200;
395
-        } catch(\Exception $e) {
395
+        }catch (\Exception $e) {
396 396
             Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData());
397 397
             $message = t('Bulk insert rolled back');
398 398
         }
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
         /** @var CustomerTableMap $tableMap */
416 416
         $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap());
417
-        foreach($this->list->getData() as $data) {
417
+        foreach ($this->list->getData() as $data) {
418 418
             $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data);
419 419
         }
420 420
         return $return;
@@ -431,23 +431,23 @@  discard block
 block discarded – undo
431 431
         try {
432 432
             $this->paginate();
433 433
             if (null !== $this->list) {
434
-                if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
434
+                if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
435 435
                     $return = $this->extractDataWithFormat();
436
-                } else {
436
+                }else {
437 437
                     $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false);
438 438
                 }
439 439
                 $total = 0;
440 440
                 $pages = 0;
441
-                if($this->list instanceof PropelModelPager) {
441
+                if ($this->list instanceof PropelModelPager) {
442 442
                     $total = $this->list->getNbResults();
443 443
                     $pages = $this->list->getLastPage();
444
-                } elseif($this->list instanceof ArrayCollection) {
444
+                } elseif ($this->list instanceof ArrayCollection) {
445 445
                     $total = count($return);
446 446
                     $pages = 1;
447 447
                 }
448 448
             }
449
-        } catch (\Exception $e) {
450
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
449
+        }catch (\Exception $e) {
450
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
451 451
         }
452 452
 
453 453
         return array($return, $total, $pages);
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         $return = array();
466 466
         if (NULL === $model || !method_exists($model, 'toArray')) {
467 467
             $code = 404;
468
-        } else {
468
+        }else {
469 469
             $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
470 470
         }
471 471
 
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
             $objects = scandir($dir);
20 20
             foreach ($objects as $object) {
21 21
                 if ($object != "." && $object != "..") {
22
-                    if (filetype($dir . "/" . $object) == "dir") {
23
-                        self::deleteDir($dir . "/" . $object);
24
-                    } else {
25
-                        unlink($dir . "/" . $object);
22
+                    if (filetype($dir."/".$object) == "dir") {
23
+                        self::deleteDir($dir."/".$object);
24
+                    }else {
25
+                        unlink($dir."/".$object);
26 26
                     }
27 27
                 }
28 28
             }
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $rootDirs = array("css", "js", "media", "font");
40 40
         foreach ($rootDirs as $dir) {
41
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
41
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
42 42
                 try {
43
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
44
-                } catch (\Exception $e) {
43
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
44
+                }catch (\Exception $e) {
45 45
                     Logger::log($e->getMessage());
46 46
                 }
47 47
             }
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
     {
58 58
         try {
59 59
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
60
-                throw new \Exception(t('Can\'t create directory ') . $dir);
60
+                throw new \Exception(t('Can\'t create directory ').$dir);
61 61
             }
62
-        } catch (\Exception $e) {
62
+        }catch (\Exception $e) {
63 63
             Logger::log($e->getMessage(), LOG_WARNING);
64 64
             if (!file_exists(dirname($dir))) {
65
-                throw new GeneratorException($e->getMessage() . $dir);
65
+                throw new GeneratorException($e->getMessage().$dir);
66 66
             }
67 67
         }
68 68
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function getTemplatePath()
75 75
     {
76
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
76
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
77 77
         return realpath($path);
78 78
     }
79 79
 
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
      * @throws GeneratorException
92 92
      */
93 93
     public static function checkCustomNamespaceApi($namespace) {
94
-        if(!empty($namespace)) {
95
-            if(class_exists($namespace)) {
94
+        if (!empty($namespace)) {
95
+            if (class_exists($namespace)) {
96 96
                 $reflector = new \ReflectionClass($namespace);
97
-                if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
97
+                if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
98 98
                     throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501);
99
-                } elseif(!$reflector->isAbstract()) {
99
+                } elseif (!$reflector->isAbstract()) {
100 100
                     throw new GeneratorException(t('La clase definida debe ser abstracta'), 501);
101 101
                 }
102
-            } else {
102
+            }else {
103 103
                 throw new GeneratorException(t('La clase definida para extender la API no existe'), 501);
104 104
             }
105 105
         }
Please login to merge, or discard this patch.
src/base/config/LoginForm.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
             ))
38 38
             ->addButton('submit', t("Acceder como {{username}}"))
39 39
             ->addButton("cancel", t("Cancelar"), "button", array(
40
-                "onclick" => "javacript:location.href = \"" . Router::getInstance()->getRoute('') . "\";",
40
+                "onclick" => "javacript:location.href = \"".Router::getInstance()->getRoute('')."\";",
41 41
                 "class" => "btn-link",
42 42
             ));
43 43
     }
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
@@ -83,9 +83,9 @@
 block discarded – undo
83 83
             'class' => 'btn-warning md-default',
84 84
             'icon' => 'fa-plus',
85 85
         ];
86
-        if(Config::getParam('admin.version', 'v1') === 'v1') {
87
-            $add['onclick'] = 'javascript:addNewField(document.getElementById("' . $this->getName() . '"));';
88
-        } else {
86
+        if (Config::getParam('admin.version', 'v1') === 'v1') {
87
+            $add['onclick'] = 'javascript:addNewField(document.getElementById("'.$this->getName().'"));';
88
+        }else {
89 89
             $add['ng-click'] = 'addNewField()';
90 90
         }
91 91
         $this->addButton('submit', t('Guardar configuración'), 'submit', array(
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function init()
76 76
     {
77
-        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE);
77
+        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE);
78 78
         if (empty($this->routing) || Config::getParam('debug', true)) {
79 79
             $this->debugLoad();
80
-        } else {
81
-            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE);
80
+        }else {
81
+            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE);
82 82
         }
83 83
         $this->checkExternalModules(false);
84 84
         $this->setLoaded();
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
         }
117 117
 
118 118
         $notFoundRoute = Config::getParam('route.404');
119
-        if(null !== $notFoundRoute) {
119
+        if (null !== $notFoundRoute) {
120 120
             Request::getInstance()->redirect($this->getRoute($notFoundRoute, true));
121
-        } else {
121
+        }else {
122 122
             return $template->render('error.html.twig', array(
123 123
                 'exception' => $exception,
124 124
                 'trace' => $exception->getTraceAsString(),
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
         try {
170 170
             //Search action and execute
171 171
             return $this->searchAction($route);
172
-        } catch (AccessDeniedException $e) {
173
-            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']);
172
+        }catch (AccessDeniedException $e) {
173
+            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']);
174 174
             return Admin::staticAdminLogon($route);
175
-        } catch (RouterException $r) {
175
+        }catch (RouterException $r) {
176 176
             Logger::log($r->getMessage(), LOG_WARNING);
177
-        } catch (\Exception $e) {
177
+        }catch (\Exception $e) {
178 178
             Logger::log($e->getMessage(), LOG_ERR);
179 179
             throw $e;
180 180
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     protected function searchAction($route)
194 194
     {
195
-        Logger::log('Searching action to execute: ' . $route, LOG_INFO);
195
+        Logger::log('Searching action to execute: '.$route, LOG_INFO);
196 196
         //Revisamos si tenemos la ruta registrada
197 197
         $parts = parse_url($route);
198 198
         $path = array_key_exists('path', $parts) ? $parts['path'] : $route;
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
                 /** @var $class \PSFS\base\types\Controller */
208 208
                 $class = RouterHelper::getClassToCall($action);
209 209
                 try {
210
-                    if($this->checkRequirements($action, $get)) {
210
+                    if ($this->checkRequirements($action, $get)) {
211 211
                         return $this->executeCachedRoute($route, $action, $class, $get);
212
-                    } else {
212
+                    }else {
213 213
                         throw new RouterException(t('La ruta no es válida'), 400);
214 214
                     }
215
-                } catch (\Exception $e) {
215
+                }catch (\Exception $e) {
216 216
                     Logger::log($e->getMessage(), LOG_ERR);
217 217
                     throw $e;
218 218
                 }
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
      * @return bool
228 228
      */
229 229
     private function checkRequirements(array $action, $params = []) {
230
-        if(!empty($params) && !empty($action['requirements'])) {
230
+        if (!empty($params) && !empty($action['requirements'])) {
231 231
             $checked = 0;
232
-            foreach(array_keys($params) as $key) {
233
-                if(in_array($key, $action['requirements'], true)) {
232
+            foreach (array_keys($params) as $key) {
233
+                if (in_array($key, $action['requirements'], true)) {
234 234
                     $checked++;
235 235
                 }
236 236
             }
237 237
             $valid = count($action['requirements']) === $checked;
238
-        } else {
238
+        }else {
239 239
             $valid = true;
240 240
         }
241 241
         return $valid;
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $this->checkExternalModules();
286 286
         if (file_exists($modulesPath)) {
287 287
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
288
-            if($modules->hasResults()) {
288
+            if ($modules->hasResults()) {
289 289
                 foreach ($modules->getIterator() as $modulePath) {
290 290
                     $module = $modulePath->getBasename();
291
-                    $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
291
+                    $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
292 292
                 }
293 293
             }
294 294
         }
295
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE);
295
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE);
296 296
     }
297 297
 
298 298
     /**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             $home_params = NULL;
309 309
             foreach ($this->routing as $pattern => $params) {
310 310
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
311
-                if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) {
311
+                if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) {
312 312
                     $home_params = $params;
313 313
                 }
314 314
                 unset($method);
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
     private function inspectDir($origen, $namespace = 'PSFS', $routing = [])
331 331
     {
332 332
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name('*.php');
333
-        if($files->hasResults()) {
333
+        if ($files->hasResults()) {
334 334
             foreach ($files->getIterator() as $file) {
335
-                if($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) {
336
-                    $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
337
-                } else {
335
+                if ($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) {
336
+                    $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
337
+                }else {
338 338
                     $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname()));
339 339
                 }
340
-                $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
340
+                $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
341 341
             }
342 342
         }
343 343
         $this->finder = new Finder();
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     private function addRouting($namespace, &$routing, $module = 'PSFS')
367 367
     {
368 368
         if (self::exists($namespace)) {
369
-            if(I18nHelper::checkI18Class($namespace)) {
369
+            if (I18nHelper::checkI18Class($namespace)) {
370 370
                 return $routing;
371 371
             }
372 372
             $reflection = new \ReflectionClass($namespace);
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             if (!$this->domains) {
409 409
                 $this->domains = [];
410 410
             }
411
-            $domain = '@' . $class->getConstant('DOMAIN') . '/';
411
+            $domain = '@'.$class->getConstant('DOMAIN').'/';
412 412
             if (!array_key_exists($domain, $this->domains)) {
413 413
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
414 414
             }
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
      */
425 425
     public function simpatize()
426 426
     {
427
-        $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php';
428
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
427
+        $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php';
428
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
429 429
         $this->generateSlugs($absoluteTranslationFileName);
430 430
         GeneratorHelper::createDir(CONFIG_DIR);
431
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
431
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
432 432
 
433 433
         return $this;
434 434
     }
@@ -444,18 +444,18 @@  discard block
 block discarded – undo
444 444
     public function getRoute($slug = '', $absolute = FALSE, array $params = [])
445 445
     {
446 446
         if ('' === $slug) {
447
-            return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/';
447
+            return $absolute ? Request::getInstance()->getRootUrl().'/' : '/';
448 448
         }
449 449
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
450 450
             throw new RouterException(t('No existe la ruta especificada'));
451 451
         }
452
-        $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
452
+        $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
453 453
         if (!empty($params)) {
454 454
             foreach ($params as $key => $value) {
455
-                $url = str_replace('{' . $key . '}', $value, $url);
455
+                $url = str_replace('{'.$key.'}', $value, $url);
456 456
             }
457 457
         } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) {
458
-            $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
458
+            $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
459 459
         }
460 460
 
461 461
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -474,15 +474,15 @@  discard block
 block discarded – undo
474 474
      * @param string $method
475 475
      */
476 476
     private function checkPreActions($class, $method) {
477
-        $preAction = 'pre' . ucfirst($method);
478
-        if(method_exists($class, $preAction)) {
477
+        $preAction = 'pre'.ucfirst($method);
478
+        if (method_exists($class, $preAction)) {
479 479
             Logger::log(t('Pre action invoked'));
480 480
             try {
481
-                if(false === call_user_func_array([$class, $preAction])) {
481
+                if (false === call_user_func_array([$class, $preAction])) {
482 482
                     Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]);
483 483
                     error_clear_last();
484 484
                 }
485
-            } catch (\Exception $e) {
485
+            }catch (\Exception $e) {
486 486
                 Logger::log($e->getMessage(), LOG_ERR, [$class, $method]);
487 487
             }
488 488
         }
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      */
500 500
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
501 501
     {
502
-        Logger::log('Executing route ' . $route, LOG_INFO);
502
+        Logger::log('Executing route '.$route, LOG_INFO);
503 503
         $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams());
504 504
         Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action);
505 505
         $cache = Cache::needCache();
@@ -507,9 +507,9 @@  discard block
 block discarded – undo
507 507
         $return = null;
508 508
         if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) {
509 509
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
510
-            $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache);
510
+            $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache);
511 511
             if (NULL !== $cachedData) {
512
-                $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON);
512
+                $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON);
513 513
                 Template::getInstance()->renderCache($cachedData, $headers);
514 514
                 $execute = FALSE;
515 515
             }
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
     private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath)
555 555
     {
556 556
         $extModule = $modulePath->getBasename();
557
-        $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
558
-        if(file_exists($moduleAutoloader)) {
557
+        $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
558
+        if (file_exists($moduleAutoloader)) {
559 559
             include_once $moduleAutoloader;
560 560
             if ($hydrateRoute) {
561
-                $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing);
561
+                $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing);
562 562
             }
563 563
         }
564 564
     }
@@ -572,16 +572,16 @@  discard block
 block discarded – undo
572 572
     {
573 573
         try {
574 574
             $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
575
-            $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
576
-            if(file_exists($externalModulePath)) {
575
+            $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
576
+            if (file_exists($externalModulePath)) {
577 577
                 $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
578
-                if($externalModule->hasResults()) {
578
+                if ($externalModule->hasResults()) {
579 579
                     foreach ($externalModule->getIterator() as $modulePath) {
580 580
                         $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath);
581 581
                     }
582 582
                 }
583 583
             }
584
-        } catch (\Exception $e) {
584
+        }catch (\Exception $e) {
585 585
             Logger::log($e->getMessage(), LOG_WARNING);
586 586
             $module = null;
587 587
         }
Please login to merge, or discard this patch.
src/base/Request.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public static function header($name, $default = null)
147 147
     {
148
-        return self::getInstance()->getHeader($name,  $default);
148
+        return self::getInstance()->getHeader($name, $default);
149 149
     }
150 150
 
151 151
     /**
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
         $header = null;
159 159
         if ($this->hasHeader($name)) {
160 160
             $header = $this->header[$name];
161
-        } else if(array_key_exists('h_' . strtolower($name), $this->query)) {
162
-            $header = $this->query['h_' . strtolower($name)];
163
-        } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) {
164
-            $header = $this->server['HTTP_' . strtoupper(str_replace('-', '_', $name))];
161
+        }else if (array_key_exists('h_'.strtolower($name), $this->query)) {
162
+            $header = $this->query['h_'.strtolower($name)];
163
+        }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) {
164
+            $header = $this->server['HTTP_'.strtoupper(str_replace('-', '_', $name))];
165 165
         }
166 166
         return $header ?: $default;
167 167
     }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             $url = $this->getServer('HTTP_ORIGIN');
261 261
         }
262 262
         ob_start();
263
-        header('Location: ' . $url);
263
+        header('Location: '.$url);
264 264
         ob_end_clean();
265 265
         Security::getInstance()->updateSession();
266 266
         exit(t('Redireccionando...'));
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
         $url = $this->getServerName();
307 307
         $protocol = $hasProtocol ? $this->getProtocol() : '';
308 308
         if (!empty($protocol)) {
309
-            $url = $protocol . $url;
309
+            $url = $protocol.$url;
310 310
         }
311 311
         if (!in_array((integer)$this->getServer('SERVER_PORT'), [80, 443], true)) {
312
-            $url .= ':' . $this->getServer('SERVER_PORT');
312
+            $url .= ':'.$this->getServer('SERVER_PORT');
313 313
         }
314 314
         return $url;
315 315
     }
Please login to merge, or discard this patch.