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