Passed
Push — master ( 0b5e67...b24160 )
by Fran
03:22
created
src/base/types/Api.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             $tableMap = $this->getTableMap();
175 175
             try {
176 176
                 $column = $tableMap->getColumnByPhpName($field);
177
-            } catch(\Exception $e) {
177
+            }catch (\Exception $e) {
178 178
                 Logger::log($e->getMessage(), LOG_ERR);
179 179
                 $column = null;
180 180
             }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
          *
187 187
          * @param ModelCriteria $query
188 188
          */
189
-        private function addOrders(ModelCriteria &$query)
189
+        private function addOrders(ModelCriteria & $query)
190 190
         {
191 191
             $orderAdded = FALSE;
192 192
             foreach ($this->order->getOrders() as $field => $direction) {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                     $orderAdded = TRUE;
195 195
                     if ($direction === Order::ASC) {
196 196
                         $query->addAscendingOrderByColumn($column->getPhpName());
197
-                    } else {
197
+                    }else {
198 198
                         $query->addDescendingOrderByColumn($column->getPhpName());
199 199
                     }
200 200
                 }
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
          * Method that add a new field with the Label of the row
209 209
          */
210 210
         private function addDefaultListField() {
211
-            if(!in_array(self::API_LIST_NAME_FIELD, $this->extraColumns)) {
211
+            if (!in_array(self::API_LIST_NAME_FIELD, $this->extraColumns)) {
212 212
                 $tableMap = $this->getTableMap();
213 213
                 $column = null;
214
-                if($tableMap->hasColumn('NAME')) {
214
+                if ($tableMap->hasColumn('NAME')) {
215 215
                     $column = $tableMap->getColumn('NAME');
216
-                } elseif($tableMap->hasColumn('TITLE')) {
216
+                } elseif ($tableMap->hasColumn('TITLE')) {
217 217
                     $column = $tableMap->getColumn('TITLE');
218
-                } elseif($tableMap->hasColumn('LABEL')) {
218
+                } elseif ($tableMap->hasColumn('LABEL')) {
219 219
                     $column = $tableMap->getColumn('LABEL');
220 220
                 }
221
-                if(null !== $column) {
221
+                if (null !== $column) {
222 222
                     $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD;
223
-                } else {
223
+                }else {
224 224
                     $this->addClassListName($tableMap);
225 225
                 }
226 226
             }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
          *
232 232
          * @param ModelCriteria $query
233 233
          */
234
-        private function addExtraColumns(ModelCriteria &$query)
234
+        private function addExtraColumns(ModelCriteria & $query)
235 235
         {
236 236
             $this->addDefaultListField();
237 237
             if (!empty($this->extraColumns)) {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
          *
247 247
          * @param ModelCriteria $query
248 248
          */
249
-        protected function joinTables(ModelCriteria &$query)
249
+        protected function joinTables(ModelCriteria & $query)
250 250
         {
251 251
             //TODO for specific implementations
252 252
         }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
          */
257 257
         protected function parseExtraColumns() {
258 258
             $columns = [];
259
-            foreach($this->extraColumns as $key => $columnName) {
259
+            foreach ($this->extraColumns as $key => $columnName) {
260 260
                 $columns[$columnName] = strtolower($columnName);
261 261
             }
262 262
             return $columns;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
          *
268 268
          * @param ModelCriteria $query
269 269
          */
270
-        private function addFilters(ModelCriteria &$query)
270
+        private function addFilters(ModelCriteria & $query)
271 271
         {
272 272
             if (count($this->query) > 0) {
273 273
                 foreach ($this->query as $field => $value) {
@@ -285,28 +285,28 @@  discard block
 block discarded – undo
285 285
                             $text = preg_replace('/(\'|\")/', '', $value);
286 286
                             $text = preg_replace('/\ /', '%', $text);
287 287
                             $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE);
288
-                        } else {
288
+                        }else {
289 289
                             $query->filterBy($tableField, $value, Criteria::EQUAL);
290 290
                         }
291
-                    } elseif(self::API_COMBO_FIELD === $field) {
291
+                    } elseif (self::API_COMBO_FIELD === $field) {
292 292
                         $exp = 'CONCAT(';
293 293
                         $sep = '';
294 294
                         $tablemap = $this->getTableMap();
295
-                        foreach($tablemap->getColumns() as $column) {
296
-                            if($column->isText()) {
297
-                                $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")';
295
+                        foreach ($tablemap->getColumns() as $column) {
296
+                            if ($column->isText()) {
297
+                                $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")';
298 298
                                 $sep = ', " ", ';
299 299
                             }
300 300
                         }
301
-                        foreach($this->extraColumns as $extra => $name) {
302
-                            $exp .= $sep . $extra;
301
+                        foreach ($this->extraColumns as $extra => $name) {
302
+                            $exp .= $sep.$extra;
303 303
                             $sep = ', " ", ';
304 304
                         }
305 305
                         $exp .= ")";
306 306
                         $text = preg_replace('/(\'|\")/', '', $value);
307 307
                         $text = preg_replace('/\ /', '%', $text);
308
-                        $query->where($exp . Criteria::LIKE . '"%' . $text . '%"');
309
-                    } else {
308
+                        $query->where($exp.Criteria::LIKE.'"%'.$text.'%"');
309
+                    }else {
310 310
                         $tableField = null;
311 311
                     }
312 312
                 }
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
                 list($page, $limit) = $this->extractPagination();
329 329
                 if ($limit == -1) {
330 330
                     $this->list = $query->find($this->con);
331
-                } else {
331
+                }else {
332 332
                     $this->list = $query->paginate($page, $limit, $this->con);
333 333
                 }
334
-            } catch (\Exception $e) {
334
+            }catch (\Exception $e) {
335 335
                 Logger::log($e->getMessage(), LOG_ERR);
336 336
             }
337 337
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 $this->joinTables($query);
349 349
                 $this->addExtraColumns($query);
350 350
                 $this->model = $query->findPk($pk);
351
-            } catch (\Exception $e) {
351
+            }catch (\Exception $e) {
352 352
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
353 353
             }
354 354
         }
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
                     $saved = TRUE;
437 437
                     $model = $this->model->toArray();
438 438
                 }
439
-            } catch (\Exception $e) {
440
-                $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage();
439
+            }catch (\Exception $e) {
440
+                $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage();
441 441
                 Logger::log($e->getMessage(), LOG_ERR);
442 442
             }
443 443
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
                         $this->model->delete($this->con);
467 467
                         $deleted = TRUE;
468 468
                     }
469
-                } catch (\Exception $e) {
469
+                }catch (\Exception $e) {
470 470
                     $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados');
471 471
                     Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
472 472
                 }
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
                         $updated = TRUE;
501 501
                         $status = 200;
502 502
                         $model = $this->model->toArray();
503
-                    } else {
503
+                    }else {
504 504
                         $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
505 505
                     }
506
-                } catch(\Exception $e) {
506
+                }catch (\Exception $e) {
507 507
                     $model = $e->getMessage();
508 508
                     Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
509 509
                 }
510
-            } else {
510
+            }else {
511 511
                 $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
512 512
             }
513 513
 
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
          */
520 520
         private function extractQuery()
521 521
         {
522
-            $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query");
522
+            $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query");
523 523
             /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */
524 524
             $query = $queryReflector->getMethod('create')->invoke($this->con);
525 525
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
             if (null !== $this->con && $this->con->inTransaction()) {
564 564
                 if ($status === 200) {
565 565
                     $this->con->commit();
566
-                } else {
566
+                }else {
567 567
                     $this->con->rollBack();
568 568
                 }
569 569
             }
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
             return $this->render('api.admin.html.twig', array(
608 608
                 "api"    => $this->getApi(),
609 609
                 "domain" => $this->domain,
610
-                "url"    => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)),
610
+                "url"    => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)),
611 611
             ), [], '');
612 612
         }
613 613
 
@@ -641,12 +641,12 @@  discard block
 block discarded – undo
641 641
             $pages = 0;
642 642
             try {
643 643
                 $this->paginate();
644
-                if(null !== $this->list) {
644
+                if (null !== $this->list) {
645 645
                     $return = $this->list->toArray();
646 646
                     $total = $this->list->getNbResults();
647 647
                     $pages = $this->list->getLastPage();
648 648
                 }
649
-            } catch (\Exception $e) {
649
+            }catch (\Exception $e) {
650 650
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
651 651
             }
652 652
 
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
             $return = array();
666 666
             if (NULL === $model && method_exists($model, 'toArray')) {
667 667
                 $code = 404;
668
-            } else {
668
+            }else {
669 669
                 $return = $model->toArray();
670 670
             }
671 671
 
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
             $pks = '';
681 681
             $sep = '';
682 682
             foreach ($tableMap->getPrimaryKeys() as $pk) {
683
-                $pks .= $sep . $pk->getFullyQualifiedName();
683
+                $pks .= $sep.$pk->getFullyQualifiedName();
684 684
                 $sep = ', "|", ';
685 685
             }
686
-            $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD;
686
+            $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD;
687 687
         }
688 688
     }
Please login to merge, or discard this patch.