Passed
Push — master ( 8912d1...9344b6 )
by Fran
02:46
created
src/base/types/traits/Api/MutationTrait.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         if (count($pks) === 1) {
82 82
             $pks = array_keys($pks);
83 83
             return [
84
-                $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD
84
+                $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD
85 85
             ];
86 86
         }
87 87
         if (count($pks) > 1) {
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
             $principal = '';
90 90
             $sep = 'CONCAT(';
91 91
             foreach ($pks as $pk) {
92
-                $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName();
93
-                $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName();
94
-                $sep = ', "' . Api::API_PK_SEPARATOR . '", ';
92
+                $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName();
93
+                $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName();
94
+                $sep = ', "'.Api::API_PK_SEPARATOR.'", ';
95 95
             }
96 96
             $principal .= ')';
97 97
             $apiPks[$principal] = Api::API_MODEL_KEY_FIELD;
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
         $pks = '';
119 119
         $sep = '';
120 120
         foreach ($tableMap->getPrimaryKeys() as $pk) {
121
-            $pks .= $sep . $pk->getFullyQualifiedName();
121
+            $pks .= $sep.$pk->getFullyQualifiedName();
122 122
             $sep = ', "|", ';
123 123
         }
124
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD;
124
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD;
125 125
     }
126 126
 
127 127
     /**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             }
144 144
             if (null !== $column) {
145 145
                 $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD;
146
-            } else {
146
+            }else {
147 147
                 $this->addClassListName($tableMap);
148 148
             }
149 149
         }
@@ -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
             }
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $this->extractApiLang();
202 202
         $model = $this->getModelNamespace();
203
-        $modelI18n = $model . 'I18n';
203
+        $modelI18n = $model.'I18n';
204 204
         if (method_exists($query, 'useI18nQuery')) {
205 205
             $query->useI18nQuery($this->lang);
206 206
             $modelParts = explode('\\', $modelI18n);
207
-            $i18nMapClass = str_replace(end($modelParts), 'Map\\' . end($modelParts), $modelI18n) . 'TableMap';
207
+            $i18nMapClass = str_replace(end($modelParts), 'Map\\'.end($modelParts), $modelI18n).'TableMap';
208 208
             /** @var TableMap $modelI18nTableMap */
209 209
             $modelI18nTableMap = $i18nMapClass::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(array_key_exists('Locale', $data) ? $data['Locale'] : (array_key_exists('locale', $data) ? $data['locale'] : Request::header(Api::HEADER_API_LANG, 'es_ES')));
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/traits/Helper/FieldHelperTrait.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -122,27 +122,27 @@  discard block
 block discarded – undo
122 122
         $behaviors = $tableMap->getBehaviors();
123 123
         foreach ($map::getFieldNames() as $field) {
124 124
             $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors);
125
-            if(null !== $fDto) {
125
+            if (null !== $fDto) {
126 126
                 $form->addField($fDto);
127 127
             }
128 128
         }
129 129
 
130
-        if(array_key_exists('i18n', $behaviors)) {
131
-            $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n');
132
-            if(null !== $relateI18n) {
130
+        if (array_key_exists('i18n', $behaviors)) {
131
+            $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n');
132
+            if (null !== $relateI18n) {
133 133
                 $i18NTableMap = $relateI18n->getLocalTable();
134
-                foreach($i18NTableMap->getColumns() as $columnMap) {
134
+                foreach ($i18NTableMap->getColumns() as $columnMap) {
135 135
                     $columnName = self::getColumnMapName($columnMap);
136
-                    if(!$form->fieldExists($columnName)) {
136
+                    if (!$form->fieldExists($columnName)) {
137 137
                         /** @var Field $fDto */
138 138
                         $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors());
139
-                        if(null !== $fDto) {
139
+                        if (null !== $fDto) {
140 140
                             $fDto->pk = false;
141 141
                             $fDto->required = true;
142
-                            if(strtolower($fDto->name) === 'locale') {
142
+                            if (strtolower($fDto->name) === 'locale') {
143 143
                                 $fDto->type = Field::COMBO_TYPE;
144 144
                                 $languages = explode(',', Config::getParam('i18n.locales', Config::getParam('default.language', 'es_ES')));
145
-                                foreach($languages as $language) {
145
+                                foreach ($languages as $language) {
146 146
                                     $fDto->data[] = [
147 147
                                         $fDto->name => $language,
148 148
                                         'Label' => t($language),
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
     {
170 170
         $column = null;
171 171
         try {
172
-            foreach($tableMap->getColumns() as $tableMapColumn) {
172
+            foreach ($tableMap->getColumns() as $tableMapColumn) {
173 173
                 $columnName = $tableMapColumn->getPhpName();
174
-                if(preg_match('/^'.$field.'$/i', $columnName)) {
174
+                if (preg_match('/^'.$field.'$/i', $columnName)) {
175 175
                     $column = $tableMapColumn;
176 176
                     break;
177 177
                 }
178 178
             }
179
-        } catch (\Exception $e) {
179
+        }catch (\Exception $e) {
180 180
             Logger::log($e->getMessage(), LOG_DEBUG);
181 181
         }
182 182
         return $column;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public static function getFieldTypes() {
189 189
         $configType = Config::getParam('api.field.case', TableMap::TYPE_PHPNAME);
190
-        switch($configType) {
190
+        switch ($configType) {
191 191
             default:
192 192
             case 'UpperCamelCase':
193 193
             case TableMap::TYPE_PHPNAME:
Please login to merge, or discard this patch.