| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| 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 |
||
| 89 | protected function _prepareForm(): self |
||
| 90 | { |
||
| 91 | /** @var \Magento\Framework\Data\Form $form */ |
||
| 92 | $form = $this->_formFactory->create( |
||
| 93 | [ |
||
| 94 | 'data' => [ |
||
| 95 | 'id' => 'edit_form', |
||
| 96 | 'action' => $this->getFormTargetUrl(), |
||
| 97 | 'method' => 'post' |
||
| 98 | ] |
||
| 99 | ] |
||
| 100 | ); |
||
| 101 | |||
| 102 | $form->setHtmlIdPrefix('purgemultiple_'); |
||
| 103 | |||
| 104 | $fieldset = $form->addFieldset( |
||
| 105 | 'base_fieldset', |
||
| 106 | [ |
||
| 107 | 'class' => 'fieldset-wide' |
||
| 108 | ] |
||
| 109 | ); |
||
| 110 | |||
| 111 | $fieldset->addField( |
||
| 112 | self::PROCESS_URL_FORM_PARAM, |
||
| 113 | 'select', |
||
| 114 | [ |
||
| 115 | 'name' => self::PROCESS_URL_FORM_PARAM, |
||
| 116 | 'label' => __('Process to run'), |
||
| 117 | 'title' => __('Process to run'), |
||
| 118 | 'required' => true, |
||
| 119 | 'values' => $this->multipleUrlsPurgeCommandsProvider->getCommandArray() |
||
| 120 | |||
| 121 | ] |
||
| 122 | ); |
||
| 123 | |||
| 124 | $fieldset->addField( |
||
| 125 | self::STORE_VIEW_FORM_PARAM, |
||
| 126 | 'select', |
||
| 127 | [ |
||
| 128 | 'name' => self::STORE_VIEW_FORM_PARAM, |
||
| 129 | 'label' => __('Store View'), |
||
| 130 | 'title' => __('Store View'), |
||
| 131 | 'required' => true, |
||
| 132 | 'values' => $this->systemStore->getStoreValuesForForm(false, true) |
||
| 133 | ] |
||
| 134 | ); |
||
| 135 | |||
| 136 | $form->setUseContainer(true); |
||
| 137 | $this->setForm($form); |
||
| 138 | |||
| 139 | return parent::_prepareForm(); |
||
| 140 | } |
||
| 141 | |||
| 150 |