| Conditions | 22 |
| Paths | 3457 |
| Total Lines | 226 |
| Code Lines | 177 |
| 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 declare(strict_types=1); |
||
| 51 | $bvisible = Request::getString('bvisible', '0', 'POST'); |
||
| 52 | $bmodule = Request::getArray('bmodule', [], 'POST'); |
||
| 53 | $btitle = Request::getString('btitle', '', 'POST'); |
||
| 54 | $bcachetime = Request::getString('bcachetime', '0', 'POST'); |
||
| 55 | $groups = Request::getArray('groups', [], 'POST'); |
||
| 56 | $options = Request::getArray('options', [], 'POST'); |
||
| 57 | $submitblock = Request::getString('submitblock', '', 'POST'); |
||
| 58 | $fct = Request::getString('fct', '', 'POST'); |
||
| 59 | $title = Request::getString('title', '', 'POST'); |
||
| 60 | $side = Request::getString('side', '0', 'POST'); |
||
| 61 | $weight = Request::getString('weight', '0', 'POST'); |
||
| 62 | $visible = Request::getString('visible', '0', 'POST'); |
||
| 63 | } |
||
| 64 | |||
| 65 | if ('list' === $op) { |
||
| 66 | // xoops_cp_header(); |
||
| 67 | $blocksadmin->listBlocks(); |
||
| 68 | require_once __DIR__ . '/admin_footer.php'; |
||
| 69 | exit(); |
||
| 70 | } |
||
| 71 | |||
| 72 | if (\in_array($op, ['edit', 'edit_ok', 'delete', 'delete_ok', 'clone', 'clone_ok'])) { |
||
| 73 | $bid = Request::getInt('bid', 0); |
||
| 74 | $ok = Request::getInt('ok', 0); |
||
| 75 | |||
| 76 | if ('clone' === $op) { |
||
| 77 | $blocksadmin->cloneBlock($bid); |
||
| 78 | } |
||
| 79 | |||
| 80 | if ('delete' === $op) { |
||
| 81 | if (1 === $ok) { |
||
| 82 | // if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 83 | // redirect_header($helper->url('admin/blocksadmin.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 84 | // } |
||
| 85 | $blocksadmin->deleteBlock($bid); |
||
| 86 | } else { |
||
| 87 | // xoops_cp_header(); |
||
| 88 | xoops_confirm(['ok' => 1, 'op' => 'delete', 'bid' => $bid], 'blocksadmin.php', constant('CO_' . $moduleDirNameUpper . '_' . 'DELETE_BLOCK_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
||
| 89 | xoops_cp_footer(); |
||
| 90 | } |
||
| 91 | } |
||
| 92 | |||
| 93 | if ('edit' === $op) { |
||
| 94 | $blocksadmin->editBlock($bid); |
||
| 95 | } |
||
| 96 | |||
| 97 | if ('edit_ok' === $op) { |
||
| 98 | $blocksadmin->updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
||
| 99 | } |
||
| 100 | |||
| 101 | if ('clone_ok' === $op) { |
||
| 102 | $blocksadmin->isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 106 | if ('order' === $op) { |
||
| 107 | $bid = Request::getArray('bid', []); |
||
| 108 | |||
| 109 | $title = Request::getArray('title', [], 'POST'); |
||
| 110 | $side = Request::getArray('side', [], 'POST'); |
||
| 111 | $weight = Request::getArray('weight', [], 'POST'); |
||
| 112 | $visible = Request::getArray('visible', [], 'POST'); |
||
| 113 | $bcachetime = Request::getArray('bcachetime', [], 'POST'); |
||
| 114 | $bmodule = Request::getArray('bmodule', [], 'POST');//mb |
||
| 115 | |||
| 116 | $oldtitle = Request::getArray('oldtitle', [], 'POST'); |
||
| 117 | $oldside = Request::getArray('oldside', [], 'POST'); |
||
| 118 | $oldweight = Request::getArray('oldweight', [], 'POST'); |
||
| 119 | $oldvisible = Request::getArray('oldvisible', [], 'POST'); |
||
| 120 | $oldgroups = Request::getArray('oldgroups', [], 'POST'); |
||
| 121 | $oldbcachetime = Request::getArray('oldcachetime', [], 'POST'); |
||
| 122 | $oldbmodule = Request::getArray('oldbmodule', [], 'POST');//mb |
||
| 123 | |||
| 124 | $blocksadmin->orderBlock( |
||
| 125 | $bid, |
||
| 126 | $oldtitle, |
||
| 127 | $oldside, |
||
| 128 | $oldweight, |
||
| 129 | $oldvisible, |
||
| 130 | $oldgroups, |
||
| 131 | $oldbcachetime, |
||
| 132 | $oldbmodule, |
||
| 133 | $title, |
||
| 134 | $weight, |
||
| 135 | $visible, |
||
| 136 | $side, |
||
| 137 | $bcachetime, |
||
| 138 | $groups, |
||
| 139 | $bmodule |
||
| 140 | ); |
||
| 141 | } |
||
| 142 | } else { |
||
| 143 | echo constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'); |
||
| 144 | } |
||
| 145 | |||
| 146 | require __DIR__ . '/admin_footer.php'; |
||
| 147 |