| Conditions | 12 |
| Paths | 512 |
| Total Lines | 104 |
| Code Lines | 79 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 129 | public function getFormTables($action = false) |
||
| 130 | { |
||
| 131 | if (false === $action) { |
||
| 132 | $action = $_SERVER['REQUEST_URI']; |
||
| 133 | } |
||
| 134 | $tdmcreate = TDMCreateHelper::getInstance(); |
||
| 135 | $isNew = $this->isNew(); |
||
| 136 | $tableName = $this->getVar('table_name'); |
||
| 137 | $tableMid = $this->getVar('table_mid'); |
||
| 138 | $title = $isNew ? sprintf(_AM_TDMCREATE_TABLE_NEW) : sprintf(_AM_TDMCREATE_TABLE_EDIT); |
||
| 139 | |||
| 140 | xoops_load('XoopsFormLoader'); |
||
| 141 | $form = new XoopsThemeForm($title, 'tableform', $action, 'post', true); |
||
| 142 | $form->setExtra('enctype="multipart/form-data"'); |
||
| 143 | |||
| 144 | $modules = $tdmcreate->getHandler('modules')->getObjects(null); |
||
| 145 | $modulesSelect = new XoopsFormSelect(_AM_TDMCREATE_TABLE_MODULES, 'table_mid', $tableMid); |
||
| 146 | $modulesSelect->addOption('', _AM_TDMCREATE_TABLE_MODSELOPT); |
||
| 147 | foreach ($modules as $mod) { |
||
| 148 | $modulesSelect->addOption($mod->getVar('mod_id'), $mod->getVar('mod_name')); |
||
| 149 | } |
||
| 150 | $form->addElement($modulesSelect, true); |
||
| 151 | |||
| 152 | $tableNameText = new XoopsFormText(_AM_TDMCREATE_TABLE_NAME, 'table_name', 40, 150, $tableName); |
||
| 153 | $tableNameText->setDescription(_AM_TDMCREATE_TABLE_NAME_DESC); |
||
| 154 | $form->addElement($tableNameText, true); |
||
| 155 | |||
| 156 | $tableSoleNameText = new XoopsFormText(_AM_TDMCREATE_TABLE_SOLENAME, 'table_solename', 40, 150, $this->getVar('table_solename')); |
||
| 157 | $tableSoleNameText->setDescription(_AM_TDMCREATE_TABLE_SOLENAME_DESC); |
||
| 158 | $form->addElement($tableSoleNameText, true); |
||
| 159 | |||
| 160 | $radioCategory = $isNew ? 0 : $this->getVar('table_category'); |
||
| 161 | $category = new XoopsFormRadioYN(_AM_TDMCREATE_TABLE_CATEGORY, 'table_category', $radioCategory); |
||
| 162 | $category->setDescription(_AM_TDMCREATE_TABLE_CATEGORY_DESC); |
||
| 163 | $form->addElement($category); |
||
| 164 | |||
| 165 | $tableFieldname = new XoopsFormText(_AM_TDMCREATE_TABLE_FIELDNAME, 'table_fieldname', 30, 50, $this->getVar('table_fieldname')); |
||
| 166 | $tableFieldname->setDescription(_AM_TDMCREATE_TABLE_FIELDNAME_DESC); |
||
| 167 | $form->addElement($tableFieldname); |
||
| 168 | |||
| 169 | $tableNumbFileds = new XoopsFormText(_AM_TDMCREATE_TABLE_NBFIELDS, 'table_nbfields', 10, 25, $this->getVar('table_nbfields')); |
||
| 170 | $tableNumbFileds->setDescription(_AM_TDMCREATE_TABLE_NBFIELDS_DESC); |
||
| 171 | $form->addElement($tableNumbFileds, true); |
||
| 172 | |||
| 173 | if (!$isNew) { |
||
| 174 | $tableOrder = new XoopsFormText(_AM_TDMCREATE_TABLE_ORDER, 'table_order', 5, 10, $this->getVar('table_order')); |
||
| 175 | $tableOrder->setDescription(_AM_TDMCREATE_TABLE_ORDER_DESC); |
||
| 176 | $form->addElement($tableOrder, true); |
||
| 177 | } |
||
| 178 | |||
| 179 | $getTableImage = $this->getVar('table_image'); |
||
| 180 | $tableImage = $getTableImage ?: 'blank.gif'; |
||
| 181 | $icons32Directory = '/Frameworks/moduleclasses/icons/32'; |
||
| 182 | $uploadsDirectory = '/uploads/tdmcreate/images/tables'; |
||
| 183 | $iconsDirectory = is_dir(XOOPS_ROOT_PATH.$icons32Directory) ? $icons32Directory : $uploadsDirectory; |
||
| 184 | |||
| 185 | $imgtray1 = new XoopsFormElementTray(_AM_TDMCREATE_TABLE_IMAGE, '<br>'); |
||
| 186 | $imgpath1 = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, ".{$iconsDirectory}/"); |
||
| 187 | $imageSelect1 = new XoopsFormSelect($imgpath1, 'table_image', $tableImage, 10); |
||
| 188 | $imageArray1 = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH.$iconsDirectory); |
||
| 189 | foreach ($imageArray1 as $image1) { |
||
| 190 | $imageSelect1->addOption("{$image1}", $image1); |
||
| 191 | } |
||
| 192 | $imageSelect1->setExtra("onchange='showImgSelected(\"image1\", \"table_image\", \"".$iconsDirectory.'", "", "'.XOOPS_URL."\")'"); |
||
| 193 | $imgtray1->addElement($imageSelect1, false); |
||
| 194 | $imgtray1->addElement(new XoopsFormLabel('', "<br><img src='".XOOPS_URL.'/'.$iconsDirectory.'/'.$tableImage."' name='image1' id='image1' alt='' />")); |
||
| 195 | $fileseltray1 = new XoopsFormElementTray('', '<br>'); |
||
| 196 | $fileseltray1->addElement(new XoopsFormFile(_AM_TDMCREATE_FORMUPLOAD, 'attachedfile', $tdmcreate->getConfig('maxsize'))); |
||
| 197 | $fileseltray1->addElement(new XoopsFormLabel('')); |
||
| 198 | $imgtray1->addElement($fileseltray1); |
||
| 199 | $imgtray1->setDescription(_AM_TDMCREATE_TABLE_IMAGE_DESC); |
||
| 200 | $form->addElement($imgtray1); |
||
| 201 | |||
| 202 | $tableAutoincrement = $this->isNew() ? 1 : $this->getVar('table_autoincrement'); |
||
| 203 | $checkTableAutoincrement = new XoopsFormRadioYN(_AM_TDMCREATE_TABLE_AUTO_INCREMENT, 'table_autoincrement', $tableAutoincrement); |
||
| 204 | $checkTableAutoincrement->setDescription(_AM_TDMCREATE_TABLE_AUTO_INCREMENT_DESC); |
||
| 205 | $form->addElement($checkTableAutoincrement); |
||
| 206 | |||
| 207 | $optionsTray = new XoopsFormElementTray(_OPTIONS, '<br>'); |
||
| 208 | |||
| 209 | $tableCheckAll = new XoopsFormCheckBox('', 'tablebox', 1); |
||
| 210 | $tableCheckAll->addOption('allbox', _AM_TDMCREATE_TABLE_ALL); |
||
| 211 | $tableCheckAll->setExtra(' onclick="xoopsCheckAll(\'tableform\', \'tablebox\');" '); |
||
| 212 | $tableCheckAll->setClass('xo-checkall'); |
||
| 213 | $optionsTray->addElement($tableCheckAll); |
||
| 214 | // Options |
||
| 215 | $checkbox = new XoopsFormCheckbox(' ', 'table_option', $this->getOptionsTables(), '<br>'); |
||
| 216 | $checkbox->setDescription(_AM_TDMCREATE_OPTIONS_DESC); |
||
| 217 | foreach ($this->options as $option) { |
||
| 218 | $checkbox->addOption($option, self::getDefinedLanguage('_AM_TDMCREATE_TABLE_'.strtoupper($option))); |
||
| 219 | } |
||
| 220 | $optionsTray->addElement($checkbox); |
||
| 221 | |||
| 222 | $optionsTray->setDescription(_AM_TDMCREATE_TABLE_OPTIONS_CHECKS_DESC); |
||
| 223 | |||
| 224 | $form->addElement($optionsTray); |
||
| 225 | |||
| 226 | $buttonTray = new XoopsFormElementTray(_REQUIRED.' <sup class="red bold">*</sup>', ''); |
||
| 227 | $buttonTray->addElement(new XoopsFormHidden('op', 'save')); |
||
| 228 | $buttonTray->addElement(new XoopsFormHidden('table_id', ($isNew ? 0 : $this->getVar('table_id')))); |
||
| 229 | $buttonTray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
| 230 | $form->addElement($buttonTray); |
||
| 231 | |||
| 232 | return $form; |
||
| 233 | } |
||
| 429 |
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