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