| Conditions | 9 |
| Paths | 4 |
| Total Lines | 122 |
| Code Lines | 80 |
| 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 |
||
| 77 | protected function _prepareForm() |
||
| 78 | { |
||
| 79 | /** @var \Magento\Framework\Data\Form $form */ |
||
| 80 | $form = $this->_formFactory->create( |
||
| 81 | ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']] |
||
| 82 | ); |
||
| 83 | $command = $this->commandProvider->getByName($this->getFormData()->getData('command')); |
||
| 84 | |||
| 85 | $baseFieldset = $form->addFieldset('base_fieldset', ['legend' => __('Command')]); |
||
| 86 | |||
| 87 | $baseFieldset->addField( |
||
| 88 | 'command_name', |
||
| 89 | 'hidden', |
||
| 90 | [ |
||
| 91 | 'name' => 'command_name', |
||
| 92 | 'label' => __('Command Name'), |
||
| 93 | 'title' => __('Command Name'), |
||
| 94 | 'value' => $command->getName() |
||
| 95 | ] |
||
| 96 | ); |
||
| 97 | |||
| 98 | $baseFieldset->addField( |
||
| 99 | 'info_command_name', |
||
| 100 | 'text', |
||
| 101 | [ |
||
| 102 | 'name' => 'info_command_name', |
||
| 103 | 'label' => __('Command Name'), |
||
| 104 | 'title' => __('Command Name'), |
||
| 105 | 'value' => $command->getName(), |
||
| 106 | 'disabled' => true |
||
| 107 | ] |
||
| 108 | ); |
||
| 109 | |||
| 110 | $baseFieldset->addField( |
||
| 111 | 'info_command_description', |
||
| 112 | 'text', |
||
| 113 | [ |
||
| 114 | 'name' => 'info_command_description', |
||
| 115 | 'label' => __('Command Description'), |
||
| 116 | 'title' => __('Command Description'), |
||
| 117 | 'value' => $command->getDescription(), |
||
| 118 | 'disabled' => true |
||
| 119 | ] |
||
| 120 | ); |
||
| 121 | |||
| 122 | if ($command->getDefinition()->getOptions()) { |
||
| 123 | $optionsFieldset = $form->addFieldset('options_fieldset', ['legend' => __('Options')]); |
||
| 124 | $dependencyMap = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Form\Element\Dependence'); |
||
| 125 | $this->setChild('form_after', $dependencyMap); |
||
| 126 | |||
| 127 | foreach ($command->getDefinition()->getOptions() as $option) { |
||
| 128 | if ($option->acceptValue()) { |
||
| 129 | $includeFieldName = sprintf('include_%s', $option->getName()); |
||
| 130 | $valueFieldName = sprintf('command_params[--%s]', $option->getName()); |
||
| 131 | $optionsFieldset->addField( |
||
| 132 | $includeFieldName, |
||
| 133 | 'select', |
||
| 134 | [ |
||
| 135 | 'name' => $includeFieldName, |
||
| 136 | 'label' => $option->getName(), |
||
| 137 | 'title' => $option->getName(), |
||
| 138 | 'required' => false, |
||
| 139 | 'options' => ['0' => __('Exclude'), '1' => __('Include')], |
||
| 140 | 'note' => $option->getDescription() |
||
| 141 | ] |
||
| 142 | ); |
||
| 143 | |||
| 144 | $optionsFieldset->addField( |
||
| 145 | $valueFieldName, |
||
| 146 | 'text', |
||
| 147 | [ |
||
| 148 | 'name' => $valueFieldName, |
||
| 149 | 'label' => sprintf('"%s" option value', $option->getName()), |
||
| 150 | 'title' => sprintf('"%s" option value', $option->getName()), |
||
| 151 | 'required' => $option->isValueRequired(), |
||
| 152 | 'value' => $option->acceptValue() ? ($option->getDefault() ?: '') : '' |
||
| 153 | ] |
||
| 154 | ); |
||
| 155 | |||
| 156 | $dependencyMap->addFieldMap($includeFieldName, $includeFieldName); |
||
| 157 | $dependencyMap->addFieldMap($valueFieldName, $valueFieldName); |
||
| 158 | $dependencyMap->addFieldDependence($valueFieldName, $includeFieldName, '1'); |
||
| 159 | } else { |
||
| 160 | $valueFieldName = sprintf('command_params[--%s]', $option->getName()); |
||
| 161 | $optionsFieldset->addField( |
||
| 162 | $valueFieldName, |
||
| 163 | 'select', |
||
| 164 | [ |
||
| 165 | 'name' => $valueFieldName, |
||
| 166 | 'label' => $option->getName(), |
||
| 167 | 'title' => $option->getName(), |
||
| 168 | 'required' => false, |
||
| 169 | 'options' => ['0' => __('Exclude'), '1' => __('Include')], |
||
| 170 | 'note' => $option->getDescription() |
||
| 171 | ] |
||
| 172 | ); |
||
| 173 | } |
||
| 174 | } |
||
| 175 | } |
||
| 176 | |||
| 177 | if ($command->getDefinition()->getArguments()) { |
||
| 178 | $argumentsFieldset = $form->addFieldset('arguments_fieldset', ['legend' => __('Arguments')]); |
||
| 179 | |||
| 180 | foreach ($command->getDefinition()->getArguments() as $argument) { |
||
| 181 | $argumentsFieldset->addField( |
||
| 182 | sprintf('command_params[%s]', $argument->getName()), |
||
| 183 | 'text', |
||
| 184 | [ |
||
| 185 | 'name' => sprintf('command_params[%s]', $argument->getName()), |
||
| 186 | 'label' => $argument->getName(), |
||
| 187 | 'title' => $argument->getName(), |
||
| 188 | 'required' => $argument->isRequired(), |
||
| 189 | 'value' => $argument->getDefault() ?: '', |
||
| 190 | 'note' => $argument->getDescription() |
||
| 191 | ] |
||
| 192 | ); |
||
| 193 | } |
||
| 194 | } |
||
| 195 | |||
| 196 | $this->setForm($form); |
||
| 197 | |||
| 198 | return parent::_prepareForm(); |
||
| 199 | } |
||
| 206 |
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