Conditions | 10 |
Paths | 2 |
Total Lines | 65 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
136 | public function getSettingsResponse() |
||
137 | { |
||
138 | $variables['matrixFields'] = $this->fields->getMatrixFields(); |
||
139 | |||
140 | $variables['globalSpoonedBlockTypes'] = $this->blockTypes->getByContext('global', 'fieldId', true); |
||
141 | |||
142 | // If Super Table is installed get all of the ST fields and store by child field context |
||
143 | $superTablePlugin = Craft::$app->plugins->getPlugin('super-table'); |
||
144 | if ($superTablePlugin && $variables['matrixFields']) { |
||
145 | $superTableService = new \verbb\supertable\services\SuperTableService(); |
||
146 | |||
147 | foreach ($variables['matrixFields'] as $matrixField) { |
||
148 | if (strpos($matrixField->context, 'superTableBlockType') === 0) { |
||
149 | $parts = explode(':', $matrixField->context); |
||
150 | if (isset($parts[1])) { |
||
151 | |||
152 | $superTableBlockTypeId = Db::idByUid('{{%supertableblocktypes}}', $parts[1]); |
||
153 | |||
154 | if ($superTableBlockTypeId) { |
||
155 | /** @var SuperTableBlockTypeModel $superTableBlockType */ |
||
156 | $superTableBlockType = $superTableService->getBlockTypeById($superTableBlockTypeId); |
||
157 | |||
158 | /** @var SuperTableField $superTableField */ |
||
159 | $superTableField = Craft::$app->fields->getFieldById($superTableBlockType->fieldId); |
||
160 | |||
161 | $variables['superTableFields'][$matrixField->context] = [ |
||
162 | 'kind' => 'Super Table', |
||
163 | 'field' => $superTableField, |
||
164 | 'child' => false |
||
165 | ]; |
||
166 | |||
167 | // If the context of _this_ field is inside a Matrix block ... then we need to do more inception |
||
168 | if (strpos($superTableField->context, 'matrixBlockType') === 0) { |
||
169 | $nestedParts = explode(':', $superTableField->context); |
||
170 | if (isset($nestedParts[1])) { |
||
171 | |||
172 | $matrixBlockTypeId = Db::idByUid('{{%matrixblocktypes}}', $nestedParts[1]); |
||
173 | |||
174 | if ($matrixBlockTypeId) { |
||
175 | /** @var craft\models\MatrixBlockType $matrixBlockType */ |
||
176 | $matrixBlockType = Craft::$app->matrix->getBlockTypeById($matrixBlockTypeId); |
||
177 | |||
178 | /** @var craft\fields\Matrix $globalField */ |
||
179 | $globalField = Craft::$app->fields->getFieldById($matrixBlockType->fieldId); |
||
180 | |||
181 | $variables['superTableFields'][$matrixField->context] = [ |
||
182 | 'kind' => 'Matrix', |
||
183 | 'field' => $globalField, |
||
184 | 'child' => [ |
||
185 | 'kind' => 'Super Table', |
||
186 | 'field' => $superTableField |
||
187 | ] |
||
188 | ]; |
||
189 | } |
||
190 | } |
||
191 | } |
||
192 | } |
||
193 | } |
||
194 | } |
||
195 | } |
||
196 | } |
||
197 | |||
198 | $this->getLoader()->configurator('#spoon-global-context-table', 'global'); |
||
199 | |||
200 | return Craft::$app->controller->renderTemplate('spoon/edit-global-context', $variables); |
||
201 | } |
||
227 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths