| Conditions | 12 |
| Paths | 14 |
| Total Lines | 42 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| 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 |
||
| 28 | public function updateEditForm($form) |
||
| 29 | { |
||
| 30 | $owner = $this->getOwner(); |
||
| 31 | $excludedModelAdmins = Config::inst()->get(ModelAdmin::class, 'excluded_modeladmins_from_ssu_extension'); |
||
| 32 | if (! in_array(get_class($owner), $excludedModelAdmins, true)) { |
||
| 33 | $excludedModels = Config::inst()->get(ModelAdmin::class, 'excluded_models_from_ssu_extension'); |
||
| 34 | if (! in_array($owner->modelClass, $excludedModels, true)) { |
||
| 35 | // This check is simply to ensure you are on the managed model you want adjust accordingly |
||
| 36 | $obj = Injector::inst()->get($owner->modelClass); |
||
| 37 | if ($obj) { |
||
| 38 | $sortFields = Config::inst()->get(ModelAdmin::class, 'sort_fields_from_ssu_extension'); |
||
| 39 | $gridField = $form->Fields()->dataFieldByName($this->sanitiseClassNameHelper($owner->modelClass)); |
||
| 40 | if ($gridField instanceof GridField) { |
||
| 41 | $config = $gridField->getConfig(); |
||
| 42 | $dbFields = $obj->config()->get('db'); |
||
| 43 | foreach ($sortFields as $sortField) { |
||
| 44 | if (isset($dbFields[$sortField])) { |
||
| 45 | // This is just a precaution to ensure we got a GridField from dataFieldByName() which you should have |
||
| 46 | if (! $config->getComponentByType(GridFieldSortableRows::class)) { |
||
| 47 | $obj = $owner->modelClass::singleton(); |
||
| 48 | if ($obj->hasExtension(Versioned::class)) { |
||
| 49 | $sorter = (new GridFieldSortableRows($sortField)) |
||
| 50 | ->setUpdateVersionedStage(Versioned::LIVE); |
||
| 51 | } else { |
||
| 52 | $sorter = new GridFieldSortableRows($sortField); |
||
| 53 | } |
||
| 54 | $config->addComponent($sorter); |
||
| 55 | } |
||
| 56 | break; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | if ($obj->hasExtension(Versioned::class) && $obj->hasStages() && class_exists(GridFieldSiteTreeState::class)) { |
||
| 61 | $config->addComponent(new GridFieldSiteTreeState()); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | |||
| 69 | return $form; |
||
| 70 | } |
||
| 112 |
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