Conditions | 5 |
Paths | 16 |
Total Lines | 54 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 declare(strict_types=1); |
||
127 | function b_xoopsfaq_recent_edit(array $options) |
||
128 | { |
||
129 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
130 | xoops_load('XoopsFormSelect'); |
||
131 | |||
132 | /** @var CategoryHandler $categoryHandler */ |
||
133 | /** @var Helper $helper */ |
||
134 | $helper = Helper::getInstance(); |
||
135 | $categoryHandler = $helper->getHandler('Category'); |
||
136 | |||
137 | $catList = $categoryHandler->getList(); |
||
138 | $optionArray = array_merge([0 => _MB_XOOPSFAQ_ALL_CATS], $catList); |
||
139 | $formSelect = new \XoopsFormSelect('category', 'options[3]', null, 3, true); |
||
140 | $formSelect->addOptionArray($optionArray); |
||
141 | $selOptions = (false === mb_strpos($options[3], ',')) ? $options[3] : explode(',', $options[3]); |
||
142 | $formSelect->setValue($selOptions); |
||
143 | $selectCat = $formSelect->render(); |
||
144 | |||
145 | $ychck = (isset($options[2]) && ($options[2] > 0)) ? ' checked' : ''; |
||
146 | $nchck = !empty($ychck) ? '' : ' checked'; |
||
147 | |||
148 | $form = '<div class="line140">' |
||
149 | . _MB_XOOPSFAQ_NUM_FAQS |
||
150 | . ' ' |
||
151 | . '<input type="number" name="options[0]" value="' |
||
152 | . $options[0] |
||
153 | . '" style="width: 5em;" min="0" class="right"><br>' |
||
154 | . _MB_XOOPSFAQ_CHARS |
||
155 | . ' <input type="number" name="options[1]" value="' |
||
156 | . $options[1] |
||
157 | . '" style="width: 5em;" min="0" class="right"> ' |
||
158 | . _MB_XOOPSFAQ_LENGTH |
||
159 | . '<br>' |
||
160 | . _MB_XOOPSFAQ_SHOW_DATE |
||
161 | . ' ' |
||
162 | . '<label for="r0">' |
||
163 | . _NO |
||
164 | . '</label>' |
||
165 | . '<input type="radio" name="options[2]" id="r0" value="0"' |
||
166 | . $nchck |
||
167 | . '> ' |
||
168 | . '<label for="r1">' |
||
169 | . _YES |
||
170 | . '</label>' |
||
171 | . '<input type="radio" name="options[2]" id="r1" value="1"' |
||
172 | . $ychck |
||
173 | . '>' |
||
174 | . '<br><br>' |
||
175 | . _MB_XOOPSFAQ_ALL_CATS_INTRO |
||
176 | . ' ' |
||
177 | . $selectCat |
||
178 | . '</div>'; |
||
179 | |||
180 | return $form; |
||
181 | } |
||
182 |