Passed
Push — master ( bc1445...5318ba )
by Fran
03:16
created
src/services/DocumentorService.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
                     if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) {
54 54
                         $modules = [
55 55
                             'name' => $module,
56
-                            'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'),
56
+                            'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'),
57 57
                         ];
58 58
                     }
59
-                } catch (\Exception $e) {
59
+                }catch (\Exception $e) {
60 60
                     $modules[] = $e->getMessage();
61 61
                 }
62 62
             }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function extractApiEndpoints(array $module)
76 76
     {
77
-        $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api';
77
+        $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api';
78 78
         $module_name = $module['name'];
79 79
         $endpoints = [];
80 80
         if (file_exists($module_path)) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             if (count($finder)) {
84 84
                 /** @var \SplFileInfo $file */
85 85
                 foreach ($finder as $file) {
86
-                    $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename());
86
+                    $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename());
87 87
                     $info = $this->extractApiInfo($namespace, $module_name);
88 88
                     if (!empty($info)) {
89 89
                         $endpoints[$namespace] = $info;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                     if (NULL !== $mInfo) {
113 113
                         $info[] = $mInfo;
114 114
                     }
115
-                } catch (\Exception $e) {
115
+                }catch (\Exception $e) {
116 116
                     Logger::getInstance()->errorLog($e->getMessage());
117 117
                 }
118 118
             }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
             } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
326 326
                 $payload = $this->extractDtoProperties($namespace);
327 327
             }
328
-        } catch (\Exception $e) {
328
+        }catch (\Exception $e) {
329 329
             Logger::getInstance()->errorLog($e->getMessage());
330 330
         }
331 331
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
                     $return = $this->extractReturn($modelNamespace, $docComments);
357 357
                     $url = array_pop($route);
358 358
                     $methodInfo = [
359
-                        'url' => str_replace("/" . $module . "/api", '', $url),
359
+                        'url' => str_replace("/".$module."/api", '', $url),
360 360
                         'method' => $info['http'],
361 361
                         'description' => $info['label'],
362 362
                         'return' => $return,
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
                     $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments);
368 368
                     $this->setQueryParams($method, $methodInfo);
369 369
                     $this->setRequestHeaders($method, $methodInfo);
370
-                } catch (\Exception $e) {
370
+                }catch (\Exception $e) {
371 371
                     jpre($e->getMessage());
372 372
                     Logger::getInstance()->errorLog($e->getMessage());
373 373
                 }
@@ -517,10 +517,10 @@  discard block
 block discarded – undo
517 517
         $formatted = [
518 518
             "swagger" => "2.0",
519 519
             "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)),
520
-            "basePath" => '/' . $module['name'] . '/api',
520
+            "basePath" => '/'.$module['name'].'/api',
521 521
             "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"],
522 522
             "info" => [
523
-                "title" => _('Documentación API módulo ') . $module['name'],
523
+                "title" => _('Documentación API módulo ').$module['name'],
524 524
                 "version" => Config::getParam('api.version', '1.0'),
525 525
                 "contact" => [
526 526
                     "name" => Config::getParam("author", "Fran López"),
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         foreach ($endpoints as $model) {
534 534
             foreach ($model as $endpoint) {
535 535
                 if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) {
536
-                    $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']);
536
+                    $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']);
537 537
                     $description = $endpoint['description'];
538 538
                     $method = strtolower($endpoint['method']);
539 539
                     $paths[$url][$method] = [
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                             $class = GeneratorHelper::extractClassFromNamespace($name);
571 571
                             $classDefinition = [
572 572
                                 'type' => 'object',
573
-                                '$ref' => '#/definitions/' . $class,
573
+                                '$ref' => '#/definitions/'.$class,
574 574
                             ];
575 575
                             $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition;
576 576
                             $dtos += self::extractSwaggerDefinition($class, $object);
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
     protected function extractDtoName($dto, $isArray = false)
606 606
     {
607 607
         $dto = explode('\\', $dto);
608
-        $modelDto = array_pop($dto) . "Dto";
608
+        $modelDto = array_pop($dto)."Dto";
609 609
         if ($isArray) {
610 610
             $modelDto .= "List";
611 611
         }
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
             foreach ($method->getParameters() as $parameter) {
691 691
                 $parameterName = $parameter->getName();
692 692
                 $types = [];
693
-                preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types);
693
+                preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types);
694 694
                 if (count($types) > 1) {
695 695
                     $methodInfo['parameters'][$parameterName] = $types[1][0];
696 696
                 }
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
@@ -58,21 +58,21 @@  discard block
 block discarded – undo
58 58
         if (count($pks) == 1) {
59 59
             $pks = array_keys($pks);
60 60
             return [
61
-                $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD
61
+                $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD
62 62
             ];
63 63
         } elseif (count($pks) > 1) {
64 64
             $apiPks = [];
65 65
             $principal = '';
66 66
             $sep = 'CONCAT(';
67 67
             foreach ($pks as $pk) {
68
-                $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName();
69
-                $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName();
70
-                $sep = ', "' . Api::API_PK_SEPARATOR . '", ';
68
+                $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName();
69
+                $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName();
70
+                $sep = ', "'.Api::API_PK_SEPARATOR.'", ';
71 71
             }
72 72
             $principal .= ')';
73 73
             $apiPks[$principal] = Api::API_MODEL_KEY_FIELD;
74 74
             return $apiPks;
75
-        } else {
75
+        }else {
76 76
             throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta'));
77 77
         }
78 78
     }
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
         $pks = '';
96 96
         $sep = '';
97 97
         foreach ($tableMap->getPrimaryKeys() as $pk) {
98
-            $pks .= $sep . $pk->getFullyQualifiedName();
98
+            $pks .= $sep.$pk->getFullyQualifiedName();
99 99
             $sep = ', "|", ';
100 100
         }
101
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD;
101
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD;
102 102
     }
103 103
 
104 104
     /**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             }
121 121
             if (null !== $column) {
122 122
                 $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD;
123
-            } else {
123
+            }else {
124 124
                 $this->addClassListName($tableMap);
125 125
             }
126 126
         }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      * @param ModelCriteria $query
133 133
      * @param string $action
134 134
      */
135
-    private function addExtraColumns(ModelCriteria &$query, $action)
135
+    private function addExtraColumns(ModelCriteria & $query, $action)
136 136
     {
137 137
         if (Api::API_ACTION_LIST === $action) {
138 138
             $this->addDefaultListField();
@@ -160,21 +160,21 @@  discard block
 block discarded – undo
160 160
     /**
161 161
      * @param ModelCriteria $query
162 162
      */
163
-    protected function checkI18n(ModelCriteria &$query)
163
+    protected function checkI18n(ModelCriteria & $query)
164 164
     {
165 165
         $model = $this->getModelNamespace();
166
-        $modelI18n = $model . 'I18n';
166
+        $modelI18n = $model.'I18n';
167 167
         if (method_exists($query, 'useI18nQuery')) {
168 168
             $default_language = explode('_', Config::getParam('default.language', 'es_ES'));
169 169
             $query->useI18nQuery(Request::header(APi::HEADER_API_LANG, $default_language[0]));
170
-            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n) . 'TableMap';
170
+            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n).'TableMap';
171 171
             /** @var TableMap $modelI18nTableMap */
172 172
             $modelI18nTableMap = $modelI18nTableMapClass::getTableMap();
173
-            foreach($modelI18nTableMap->getColumns() as $columnMap) {
174
-                if(!$columnMap->isPrimaryKey()) {
175
-                    $query->withColumn($modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName(), $columnMap->getPhpName());
176
-                } elseif(!$columnMap->isForeignKey()) {
177
-                    $query->withColumn('IFNULL(' . $modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName() . ', "'.Request::header(Api::HEADER_API_LANG, 'es').'")', $columnMap->getPhpName());
173
+            foreach ($modelI18nTableMap->getColumns() as $columnMap) {
174
+                if (!$columnMap->isPrimaryKey()) {
175
+                    $query->withColumn($modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName(), $columnMap->getPhpName());
176
+                } elseif (!$columnMap->isForeignKey()) {
177
+                    $query->withColumn('IFNULL('.$modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName().', "'.Request::header(Api::HEADER_API_LANG, 'es').'")', $columnMap->getPhpName());
178 178
                 }
179 179
             }
180 180
         }
@@ -184,23 +184,23 @@  discard block
 block discarded – undo
184 184
      * @param ActiveRecordInterface $model
185 185
      * @param array $data
186 186
      */
187
-    protected function hydrateModelFromRequest(ActiveRecordInterface &$model, array $data = []) {
187
+    protected function hydrateModelFromRequest(ActiveRecordInterface & $model, array $data = []) {
188 188
         $model->fromArray($data);
189 189
         $tableMap = $this->getTableMap();
190 190
         try {
191
-            $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n');
192
-            if(null !== $relateI18n) {
191
+            $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n');
192
+            if (null !== $relateI18n) {
193 193
                 $i18NTableMap = $relateI18n->getLocalTable();
194
-                foreach($i18NTableMap->getColumns() as $columnMap) {
195
-                    $method = 'set' . $columnMap->getPhpName();
196
-                    if(!($columnMap->isPrimaryKey() && $columnMap->isForeignKey())
194
+                foreach ($i18NTableMap->getColumns() as $columnMap) {
195
+                    $method = 'set'.$columnMap->getPhpName();
196
+                    if (!($columnMap->isPrimaryKey() && $columnMap->isForeignKey())
197 197
                         &&array_key_exists($columnMap->getPhpName(), $data)
198 198
                         && method_exists($model, $method)) {
199 199
                         $model->$method($data[$columnMap->getPhpName()]);
200 200
                     }
201 201
                 }
202 202
             }
203
-        } catch(\Exception $e) {
203
+        }catch (\Exception $e) {
204 204
             Logger::log($e->getMessage(), LOG_WARNING);
205 205
         }
206 206
     }
Please login to merge, or discard this patch.