Passed
Push — master ( c82035...9f9933 )
by Fran
02:32
created
src/base/types/traits/Generator/PropelHelperTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
      */
23 23
     private function getPropelPaths($modulePath)
24 24
     {
25
-        $moduleDir = CORE_DIR . DIRECTORY_SEPARATOR . $modulePath;
25
+        $moduleDir = CORE_DIR.DIRECTORY_SEPARATOR.$modulePath;
26 26
         GeneratorHelper::createDir($moduleDir);
27 27
         $moduleDir = realpath($moduleDir);
28
-        $configDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config';
29
-        $sqlDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Sql';
30
-        $migrationDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Migrations';
28
+        $configDir = $moduleDir.DIRECTORY_SEPARATOR.'Config';
29
+        $sqlDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Sql';
30
+        $migrationDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Migrations';
31 31
         $paths = [
32 32
             'projectDir' => $moduleDir,
33 33
             'outputDir' => $moduleDir,
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
      * @param AbstractManager $manager
91 91
      * @param string $workingDir
92 92
      */
93
-    private function setupManager(GeneratorConfig $configGenerator, AbstractManager &$manager, $workingDir = CORE_DIR)
93
+    private function setupManager(GeneratorConfig $configGenerator, AbstractManager & $manager, $workingDir = CORE_DIR)
94 94
     {
95 95
         $manager->setGeneratorConfig($configGenerator);
96
-        $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'] . DIRECTORY_SEPARATOR . 'schema.xml');
96
+        $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'].DIRECTORY_SEPARATOR.'schema.xml');
97 97
         $manager->setSchemas([$schemaFile]);
98
-        $manager->setLoggerClosure(function ($message) {
98
+        $manager->setLoggerClosure(function($message) {
99 99
             Logger::log($message, LOG_INFO);
100 100
         });
101 101
         $manager->setWorkingDirectory($workingDir);
Please login to merge, or discard this patch.
src/base/types/traits/Helper/FieldModelHelperTrait.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $fDto->entity = $relatedModel;
32 32
         $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName());
33 33
         $fDto->relatedField = $relatedField->getPhpName();
34
-        $fDto->url = Router::getInstance()->getRoute(strtolower($domain) . '-api-' . $relatedModel);
34
+        $fDto->url = Router::getInstance()->getRoute(strtolower($domain).'-api-'.$relatedModel);
35 35
         return $fDto;
36 36
     }
37 37
 
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
      * @param ModelCriteria $query
41 41
      * @param mixed $value
42 42
      */
43
-    private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null)
43
+    private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null)
44 44
     {
45 45
         $tableField = $column->getFullyQualifiedName();
46
-        if(is_array($value)) {
46
+        if (is_array($value)) {
47 47
             $query->add($tableField, $value, Criteria::IN);
48 48
         } elseif (preg_match('/^\[/', $value) && preg_match('/\]$/', $value)) {
49 49
             $query->add($tableField, explode(',', preg_replace('/(\[|\])/', '', $value)), Criteria::IN);
50 50
         } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) {
51 51
             $text = preg_replace('/(\'|\")/', '', $value);
52 52
             $text = preg_replace('/\ /', '%', $text);
53
-            $query->add($tableField, '%' . $text . '%', Criteria::LIKE);
54
-        } else {
55
-            if(null !== $column->getValueSet()) {
53
+            $query->add($tableField, '%'.$text.'%', Criteria::LIKE);
54
+        }else {
55
+            if (null !== $column->getValueSet()) {
56 56
                 $valueSet = $column->getValueSet();
57
-                if(in_array($value, $valueSet)) {
57
+                if (in_array($value, $valueSet)) {
58 58
                     $value = array_search($value, $valueSet);
59 59
                 }
60 60
             }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param string $field
70 70
      * @param mixed $value
71 71
      */
72
-    public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null)
72
+    public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null)
73 73
     {
74 74
         if ($column = self::checkFieldExists($tableMap, $field)) {
75 75
             self::addQueryFilter($column, $query, $value);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public static function extractQuery($modelNameNamespace, ConnectionInterface $con = null)
86 86
     {
87
-        $queryReflector = new \ReflectionClass($modelNameNamespace . "Query");
87
+        $queryReflector = new \ReflectionClass($modelNameNamespace."Query");
88 88
         /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */
89 89
         $query = $queryReflector->getMethod('create')->invoke($con);
90 90
 
@@ -97,37 +97,37 @@  discard block
 block discarded – undo
97 97
      * @param array $extraColumns
98 98
      * @param mixed $value
99 99
      */
100
-    public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null)
100
+    public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null)
101 101
     {
102 102
         $exp = 'CONCAT(';
103 103
         $sep = '';
104 104
         foreach ($tableMap->getColumns() as $column) {
105 105
             if ($column->isText()) {
106
-                $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")';
106
+                $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")';
107 107
                 $sep = ', " ", ';
108 108
             }
109 109
         }
110
-        foreach($tableMap->getRelations() as $relation) {
111
-            if(preg_match('/I18n$/i', $relation->getName())) {
110
+        foreach ($tableMap->getRelations() as $relation) {
111
+            if (preg_match('/I18n$/i', $relation->getName())) {
112 112
                 $localeTableMap = $relation->getLocalTable();
113 113
                 foreach ($localeTableMap->getColumns() as $column) {
114 114
                     if ($column->isText()) {
115
-                        $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")';
115
+                        $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")';
116 116
                         $sep = ', " ", ';
117 117
                     }
118 118
                 }
119 119
             }
120 120
         }
121 121
         foreach (array_keys($extraColumns) as $extra) {
122
-            if(!preg_match("/(COUNT|DISTINCT|SUM|MAX|MIN|GROUP)/i", $extra)) {
123
-                $exp .= $sep . $extra;
122
+            if (!preg_match("/(COUNT|DISTINCT|SUM|MAX|MIN|GROUP)/i", $extra)) {
123
+                $exp .= $sep.$extra;
124 124
                 $sep = ', " ", ';
125 125
             }
126 126
         }
127 127
         $exp .= ")";
128 128
         $text = preg_replace('/(\'|\")/', '', $value);
129 129
         $text = preg_replace('/\ /', '%', $text);
130
-        $query->where($exp . Criteria::LIKE . '"%' . $text . '%"');
130
+        $query->where($exp.Criteria::LIKE.'"%'.$text.'%"');
131 131
     }
132 132
 
133 133
     /**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public static function extractPrimaryKeyColumnName(TableMap $tableMap) {
138 138
         $modelPk = null;
139
-        foreach($tableMap->getPrimaryKeys() as $pk) {
139
+        foreach ($tableMap->getPrimaryKeys() as $pk) {
140 140
             $modelPk = $pk;
141 141
             break;
142 142
         }
Please login to merge, or discard this patch.
src/base/types/traits/Helper/ParameterTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function getParams()
19 19
     {
20
-        return $this->params?: [];
20
+        return $this->params ?: [];
21 21
     }
22 22
 
23 23
     /**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      * @return ParameterTrait
50 50
      */
51 51
     public function dropParam($key) {
52
-        if(array_key_exists($key, $this->params)) {
52
+        if (array_key_exists($key, $this->params)) {
53 53
             unset($this->params[$key]);
54 54
         }
55 55
         return $this;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @return mixed|null
61 61
      */
62 62
     public function getParam($key) {
63
-        if(array_key_exists($key, $this->params)) {
63
+        if (array_key_exists($key, $this->params)) {
64 64
             return $this->params[$key];
65 65
         }
66 66
         return null;
Please login to merge, or discard this patch.
src/base/types/traits/Api/ApiTrait.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
     protected function hydrateBulkRequest() {
97 97
         $class = new \ReflectionClass($this->getModelNamespace());
98 98
         $this->list = [];
99
-        foreach($this->data as $item) {
100
-            if(is_array($item)) {
101
-                if(count($this->list) < Config::getParam('api.block.limit', 1000)) {
99
+        foreach ($this->data as $item) {
100
+            if (is_array($item)) {
101
+                if (count($this->list) < Config::getParam('api.block.limit', 1000)) {
102 102
                     /** @var ActiveRecordInterface $model */
103 103
                     $model = $class->newInstance();
104 104
                     $this->hydrateModelFromRequest($model, $item);
105 105
                     $this->list[] = $model;
106
-                } else {
107
-                    Logger::log(t('Max items per bulk insert raised'), LOG_WARNING, count($this->data) . t('items'));
106
+                }else {
107
+                    Logger::log(t('Max items per bulk insert raised'), LOG_WARNING, count($this->data).t('items'));
108 108
                 }
109 109
             }
110 110
         }
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
      */
116 116
     protected function saveBulk() {
117 117
         $tablemap = $this->getTableMap();
118
-        foreach($this->list as &$model) {
118
+        foreach ($this->list as &$model) {
119 119
             $con = Propel::getWriteConnection($tablemap::DATABASE_NAME);
120 120
             try {
121 121
                 $model->save($con);
122 122
                 $con->commit();
123
-            } catch(\Exception $e) {
123
+            }catch (\Exception $e) {
124 124
                 Logger::log($e->getMessage(), LOG_ERR, $model->toArray());
125 125
                 $con->rollBack();
126 126
             }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     protected function exportList() {
134 134
         $list = [];
135 135
         /** @var ActiveRecordInterface $item */
136
-        foreach($this->list as $item) {
136
+        foreach ($this->list as $item) {
137 137
             $list[] = $item->toArray();
138 138
         }
139 139
         return $list;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      *
145 145
      * @param ModelCriteria $query
146 146
      */
147
-    protected function joinTables(ModelCriteria &$query)
147
+    protected function joinTables(ModelCriteria & $query)
148 148
     {
149 149
         //TODO for specific implementations
150 150
     }
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
      */
158 158
     protected function findPk(ModelCriteria $query, $primaryKey) {
159 159
         $pks = explode(Api::API_PK_SEPARATOR, urldecode($primaryKey));
160
-        if(count($pks) === 1 && !empty($pks[0])) {
160
+        if (count($pks) === 1 && !empty($pks[0])) {
161 161
             $query->filterByPrimaryKey($pks[0]);
162
-        } else {
162
+        }else {
163 163
             $item = 0;
164
-            foreach($this->getPkDbName() as $phpName) {
164
+            foreach ($this->getPkDbName() as $phpName) {
165 165
                 try {
166 166
                     $query->filterBy($phpName, $pks[$item]);
167 167
                     $item++;
168
-                    if($item >= count($pks)) {
168
+                    if ($item >= count($pks)) {
169 169
                         break;
170 170
                     }
171
-                } catch(\Exception $e) {
171
+                }catch (\Exception $e) {
172 172
                     Logger::log($e->getMessage(), LOG_DEBUG);
173 173
                 }
174 174
             }
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
         try {
199 199
             $query = $this->prepareQuery();
200 200
             $this->model = $this->findPk($query, $primaryKey);
201
-        } catch (\Exception $e) {
202
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
201
+        }catch (\Exception $e) {
202
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
203 203
         }
204 204
     }
205 205
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     /**
221 221
      * @param ModelCriteria $query
222 222
      */
223
-    protected function checkReturnFields(ModelCriteria &$query)
223
+    protected function checkReturnFields(ModelCriteria & $query)
224 224
     {
225 225
         $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD);
226 226
         if (null !== $returnFields) {
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
@@ -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
         }
@@ -154,22 +154,22 @@  discard block
 block discarded – undo
154 154
      * @param $action
155 155
      * @throws ApiException
156 156
      */
157
-    private function addExtraColumns(ModelCriteria &$query, $action)
157
+    private function addExtraColumns(ModelCriteria & $query, $action)
158 158
     {
159 159
         if (Api::API_ACTION_LIST === $action) {
160 160
             $this->addDefaultListField();
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
             }
@@ -196,22 +196,22 @@  discard block
 block discarded – undo
196 196
     /**
197 197
      * @param ModelCriteria $query
198 198
      */
199
-    protected function checkI18n(ModelCriteria &$query)
199
+    protected function checkI18n(ModelCriteria & $query)
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/Api.php 1 patch
Spacing   +38 added lines, -38 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) {
117 117
                     $orders = json_decode($value, true);
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
      */
130 130
     protected function extractPagination()
131 131
     {
132
-        Logger::log(static::class . ' extract pagination start', LOG_DEBUG);
132
+        Logger::log(static::class.' extract pagination start', LOG_DEBUG);
133 133
         $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1;
134 134
         $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100;
135
-        Logger::log(static::class . ' extract pagination end', LOG_DEBUG);
135
+        Logger::log(static::class.' extract pagination end', LOG_DEBUG);
136 136
         return array($page, (int)$limit);
137 137
     }
138 138
 
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
      * @param ModelCriteria $query
142 142
      * @throws \PSFS\base\exception\ApiException
143 143
      */
144
-    private function addOrders(ModelCriteria &$query)
144
+    private function addOrders(ModelCriteria & $query)
145 145
     {
146
-        Logger::log(static::class . ' extract orders start ', LOG_DEBUG);
146
+        Logger::log(static::class.' extract orders start ', LOG_DEBUG);
147 147
         $orderAdded = FALSE;
148 148
         $tableMap = $this->getTableMap();
149 149
         foreach ($this->order->getOrders() as $field => $direction) {
@@ -151,18 +151,18 @@  discard block
 block discarded – undo
151 151
                 $orderAdded = TRUE;
152 152
                 if ($direction === Order::ASC) {
153 153
                     $query->addAscendingOrderByColumn($column->getPhpName());
154
-                } else {
154
+                }else {
155 155
                     $query->addDescendingOrderByColumn($column->getPhpName());
156 156
                 }
157 157
             }
158 158
         }
159 159
         if (!$orderAdded) {
160 160
             $pks = $this->getPkDbName();
161
-            foreach(array_keys($pks) as $key) {
161
+            foreach (array_keys($pks) as $key) {
162 162
                 $query->addAscendingOrderByColumn($key);
163 163
             }
164 164
         }
165
-        Logger::log(static::class . ' extract orders end', LOG_DEBUG);
165
+        Logger::log(static::class.' extract orders end', LOG_DEBUG);
166 166
     }
167 167
 
168 168
     /**
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
      *
171 171
      * @param ModelCriteria $query
172 172
      */
173
-    protected function addFilters(ModelCriteria &$query)
173
+    protected function addFilters(ModelCriteria & $query)
174 174
     {
175 175
         if (count($this->query) > 0) {
176 176
             $tableMap = $this->getTableMap();
177 177
             foreach ($this->query as $field => $value) {
178 178
                 if (self::API_COMBO_FIELD === $field) {
179 179
                     ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
180
-                } elseif(!preg_match('/^__/', $field)) {
180
+                } elseif (!preg_match('/^__/', $field)) {
181 181
                     ApiHelper::addModelField($tableMap, $query, $field, $value);
182 182
                 }
183 183
             }
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
             list($page, $limit) = $this->extractPagination();
199 199
             if ($limit === -1) {
200 200
                 $this->list = $query->find($this->con);
201
-            } else {
201
+            }else {
202 202
                 $this->list = $query->paginate($page, $limit, $this->con);
203 203
             }
204
-        } catch (\Exception $e) {
204
+        }catch (\Exception $e) {
205 205
             Logger::log($e->getMessage(), LOG_ERR);
206 206
         }
207 207
     }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
         $code = 200;
221 221
         list($return, $total, $pages) = $this->getList();
222 222
         $message = null;
223
-        if(!$total) {
223
+        if (!$total) {
224 224
             $message = t('No se han encontrado elementos para la búsqueda');
225 225
         }
226 226
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         $pages = 1;
247 247
         $message = null;
248 248
         list($code, $return) = $this->getSingleResult($pk);
249
-        if($code !== 200) {
249
+        if ($code !== 200) {
250 250
             $message = t('No se ha encontrado el elemento solicitado');
251 251
         }
252 252
 
@@ -275,13 +275,13 @@  discard block
 block discarded – undo
275 275
                 $status = 200;
276 276
                 $saved = TRUE;
277 277
                 $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
278
-            } else {
278
+            }else {
279 279
                 $message = t('No se ha podido guardar el modelo seleccionado');
280 280
             }
281
-        } catch (\Exception $e) {
282
-            $message = t('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage();
281
+        }catch (\Exception $e) {
282
+            $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage();
283 283
             $context = [];
284
-            if(null !== $e->getPrevious()) {
284
+            if (null !== $e->getPrevious()) {
285 285
                 $context[] = $e->getPrevious()->getMessage();
286 286
             }
287 287
             Logger::log($e->getMessage(), LOG_CRIT, $context);
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
                     $updated = TRUE;
318 318
                     $status = 200;
319 319
                     $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
320
-                } else {
320
+                }else {
321 321
                     $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
322 322
                 }
323
-            } catch (\Exception $e) {
323
+            }catch (\Exception $e) {
324 324
                 $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
325 325
                 $context = [];
326
-                if(null !== $e->getPrevious()) {
326
+                if (null !== $e->getPrevious()) {
327 327
                     $context[] = $e->getPrevious()->getMessage();
328 328
                 }
329 329
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
330 330
             }
331
-        } else {
331
+        }else {
332 332
             $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar');
333 333
         }
334 334
 
@@ -356,15 +356,15 @@  discard block
 block discarded – undo
356 356
                 $this->con->beginTransaction();
357 357
                 $this->hydrateModel($pk);
358 358
                 if (NULL !== $this->model) {
359
-                    if(method_exists('clearAllReferences', $this->model)) {
359
+                    if (method_exists('clearAllReferences', $this->model)) {
360 360
                         $this->model->clearAllReferences(true);
361 361
                     }
362 362
                     $this->model->delete($this->con);
363 363
                     $deleted = TRUE;
364 364
                 }
365
-            } catch (\Exception $e) {
365
+            }catch (\Exception $e) {
366 366
                 $context = [];
367
-                if(null !== $e->getPrevious()) {
367
+                if (null !== $e->getPrevious()) {
368 368
                     $context[] = $e->getPrevious()->getMessage();
369 369
                 }
370 370
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
             $this->saveBulk();
394 394
             $saved = true;
395 395
             $status = 200;
396
-        } catch(\Exception $e) {
396
+        }catch (\Exception $e) {
397 397
             Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData());
398 398
             $message = t('Bulk insert rolled back');
399 399
         }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 
416 416
         /** @var CustomerTableMap $tableMap */
417 417
         $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap());
418
-        foreach($this->list->getData() as $data) {
418
+        foreach ($this->list->getData() as $data) {
419 419
             $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data);
420 420
         }
421 421
         return $return;
@@ -432,23 +432,23 @@  discard block
 block discarded – undo
432 432
         try {
433 433
             $this->paginate();
434 434
             if (null !== $this->list) {
435
-                if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
435
+                if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
436 436
                     $return = $this->extractDataWithFormat();
437
-                } else {
437
+                }else {
438 438
                     $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false);
439 439
                 }
440 440
                 $total = 0;
441 441
                 $pages = 0;
442
-                if($this->list instanceof PropelModelPager) {
442
+                if ($this->list instanceof PropelModelPager) {
443 443
                     $total = $this->list->getNbResults();
444 444
                     $pages = $this->list->getLastPage();
445
-                } elseif($this->list instanceof ArrayCollection) {
445
+                } elseif ($this->list instanceof ArrayCollection) {
446 446
                     $total = count($return);
447 447
                     $pages = 1;
448 448
                 }
449 449
             }
450
-        } catch (\Exception $e) {
451
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
450
+        }catch (\Exception $e) {
451
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
452 452
         }
453 453
 
454 454
         return array($return, $total, $pages);
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
         $return = array();
467 467
         if (NULL === $model || !method_exists($model, 'toArray')) {
468 468
             $code = 404;
469
-        } else {
469
+        }else {
470 470
             $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
471 471
         }
472 472
 
Please login to merge, or discard this patch.
src/controller/ConfigController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         foreach ($domains as $domain => $routes) {
36 36
             $pDomain = str_replace('@', '', $domain);
37 37
             $pDomain = str_replace('/', '', $pDomain);
38
-            $response[] = strtolower($pDomain) . '.api.secret';
38
+            $response[] = strtolower($pDomain).'.api.secret';
39 39
         }
40 40
         return $this->json($response);
41 41
     }
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function config()
53 53
     {
54
-        Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri());
55
-        if(defined('PSFS_UNIT_TESTING_EXECUTION')) {
54
+        Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri());
55
+        if (defined('PSFS_UNIT_TESTING_EXECUTION')) {
56 56
             throw new ConfigException('CONFIG');
57 57
         }
58 58
         $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig());
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 }
90 90
                 Security::getInstance()->setFlash("callback_message", t("Configuración actualizada correctamente"));
91 91
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true));
92
-            } else {
92
+            }else {
93 93
                 throw new HttpException(t('Error al guardar la configuración, prueba a cambiar los permisos'), 403);
94 94
             }
95 95
         }
Please login to merge, or discard this patch.
src/controller/GeneratorController.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
                 GeneratorHelper::checkCustomNamespaceApi($apiClass);
64 64
                 $this->gen->createStructureModule($module, false, $type, $apiClass);
65 65
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente")));
66
-                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
66
+                    Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
67 67
             } catch (Exception $e) {
68 68
                 Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
69 69
                 Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage()));
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function generateModule()
35 35
     {
36
-        Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri());
36
+        Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri());
37 37
         /* @var $form ConfigForm */
38 38
         $form = new ModuleForm();
39 39
         $form->build();
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
                 $this->gen->createStructureModule($module, false, $type, $apiClass);
65 65
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente")));
66 66
                  Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
67
-            } catch (Exception $e) {
68
-                Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
67
+            }catch (Exception $e) {
68
+                Logger::log($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
69 69
                 Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage()));
70 70
             }
71 71
         }
Please login to merge, or discard this patch.
src/base/Cache.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     {
56 56
         GeneratorHelper::createDir(dirname($path));
57 57
         if (false === FileHelper::writeFile($path, $data)) {
58
-            throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
58
+            throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ').$path);
59 59
         }
60 60
     }
61 61
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     {
70 70
         Inspector::stats('[Cache] Gathering data from cache', Inspector::SCOPE_DEBUG);
71 71
         $data = null;
72
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
72
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
73 73
         if (file_exists($absolutePath)) {
74 74
             $data = FileHelper::readFile($absolutePath);
75 75
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
86 86
     {
87 87
         Inspector::stats('[Cache] Checking expiration', Inspector::SCOPE_DEBUG);
88
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
88
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
89 89
         $lasModificationDate = filemtime($absolutePath);
90 90
         return ($lasModificationDate + $expires <= time());
91 91
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     {
153 153
         Inspector::stats('[Cache] Store data in cache', Inspector::SCOPE_DEBUG);
154 154
         $data = self::transformData($data, $transform);
155
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
155
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
156 156
         $this->saveTextToFile($data, $absolutePath);
157 157
     }
158 158
 
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     public function readFromCache($path, $expires = 300, $function = null, $transform = Cache::TEXT)
169 169
     {
170 170
         $data = null;
171
-        Inspector::stats('[Cache] Reading data from cache: ' . json_encode(['path' => $path]), Inspector::SCOPE_DEBUG);
172
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        Inspector::stats('[Cache] Reading data from cache: '.json_encode(['path' => $path]), Inspector::SCOPE_DEBUG);
172
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
173 173
             if (is_callable($function) && $this->hasExpiredCache($path, $expires)) {
174 174
                 $data = $function();
175 175
                 $this->storeData($path, $data, $transform);
176
-            } else {
176
+            }else {
177 177
                 $data = $this->getDataFromFile($path, $transform);
178 178
             }
179 179
         }
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
             $query[Api::HEADER_API_LANG] = Request::header(Api::HEADER_API_LANG, 'es');
220 220
             $filename = FileHelper::generateHashFilename($action['http'], $action['slug'], $query);
221 221
             $hashPath = FileHelper::generateCachePath($action, $query);
222
-            Inspector::stats('[Cache] Cache file calculated: ' . json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG);
222
+            Inspector::stats('[Cache] Cache file calculated: '.json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG);
223 223
             Logger::log('Cache file calculated', LOG_DEBUG, ['file' => $filename, 'hash' => $hashPath]);
224 224
         }
225 225
         return [$hashPath, $filename];
226 226
     }
227 227
 
228 228
     public function flushCache() {
229
-        if(Config::getParam('cache.data.enable', false)) {
229
+        if (Config::getParam('cache.data.enable', false)) {
230 230
             Inspector::stats('[Cache] Flushing cache', Inspector::SCOPE_DEBUG);
231 231
             $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR);
232
-            if(is_array($action)) {
233
-                $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
234
-                if(!file_exists($hashPath)) {
235
-                    $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath;
232
+            if (is_array($action)) {
233
+                $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
234
+                if (!file_exists($hashPath)) {
235
+                    $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath;
236 236
                 }
237 237
                 FileHelper::deleteDir($hashPath);
238 238
             }
Please login to merge, or discard this patch.