| Conditions | 8 |
| Paths | 2 |
| Total Lines | 63 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 50 | public function actionIndex($variables = []) |
||
| 51 | { |
||
| 52 | $variables['matrixFields'] = Spoon::$plugin->fields->getMatrixFields(); |
||
| 53 | |||
| 54 | $variables['globalSpoonedBlockTypes'] = Spoon::$plugin->blockTypes->getByContext('global', 'fieldId', true); |
||
| 55 | |||
| 56 | // If Super Table is installed get all of the ST fields and store by child field context |
||
| 57 | $superTablePlugin = \Craft::$app->plugins->getPlugin('super-table'); |
||
| 58 | if ($superTablePlugin && $variables['matrixFields']) { |
||
| 59 | $superTableService = new \verbb\supertable\services\SuperTableService(); |
||
|
|
|||
| 60 | |||
| 61 | foreach ($variables['matrixFields'] as $matrixField) { |
||
| 62 | if (strpos($matrixField->context, 'superTableBlockType') === 0) { |
||
| 63 | $parts = explode(':', $matrixField->context); |
||
| 64 | if (isset($parts[1])) { |
||
| 65 | |||
| 66 | $superTableBlockTypeId = Db::idByUid('{{%supertableblocktypes}}', $parts[1]); |
||
| 67 | |||
| 68 | /** @var \verbb\supertable\models\SuperTableBlockTypeModel $superTableBlockType */ |
||
| 69 | $superTableBlockType = $superTableService->getBlockTypeById($superTableBlockTypeId); |
||
| 70 | |||
| 71 | /** @var \verbb\supertable\fields\SuperTableField $superTableField */ |
||
| 72 | $superTableField = \Craft::$app->fields->getFieldById($superTableBlockType->fieldId); |
||
| 73 | |||
| 74 | $variables['superTableFields'][$matrixField->context] = [ |
||
| 75 | 'kind' => 'Super Table', |
||
| 76 | 'field' => $superTableField, |
||
| 77 | 'child' => false |
||
| 78 | ]; |
||
| 79 | |||
| 80 | // If the context of _this_ field is inside a Matrix block ... then we need to do more inception |
||
| 81 | if (strpos($superTableField->context, 'matrixBlockType') === 0) { |
||
| 82 | $nestedParts = explode(':', $superTableField->context); |
||
| 83 | if (isset($nestedParts[1])) { |
||
| 84 | |||
| 85 | $matrixBlockTypeId = Db::idByUid('{{%matrixblocktypes}}', $nestedParts[1]); |
||
| 86 | |||
| 87 | /** @var craft\models\MatrixBlockType $matrixBlockType */ |
||
| 88 | $matrixBlockType = \Craft::$app->matrix->getBlockTypeById($matrixBlockTypeId); |
||
| 89 | |||
| 90 | /** @var craft\fields\Matrix $globalField */ |
||
| 91 | $globalField = \Craft::$app->fields->getFieldById($matrixBlockType->fieldId); |
||
| 92 | |||
| 93 | $variables['superTableFields'][$matrixField->context] = [ |
||
| 94 | 'kind' => 'Matrix', |
||
| 95 | 'field' => $globalField, |
||
| 96 | 'child' => [ |
||
| 97 | 'kind' => 'Super Table', |
||
| 98 | 'field' => $superTableField |
||
| 99 | ] |
||
| 100 | ]; |
||
| 101 | |||
| 102 | } |
||
| 103 | } |
||
| 104 | |||
| 105 | } |
||
| 106 | } |
||
| 107 | } |
||
| 108 | } |
||
| 109 | |||
| 110 | Spoon::$plugin->loader->configurator('#spoon-global-context-table', 'global'); |
||
| 111 | |||
| 112 | return $this->renderTemplate('spoon/edit-global-context', $variables); |
||
| 113 | } |
||
| 250 |
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