Conditions | 22 |
Paths | 3457 |
Total Lines | 223 |
Code Lines | 176 |
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 |
||
50 | $bweight = Request::getString('bweight', '0', 'POST'); |
||
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 | |||
75 | if ('clone' === $op) { |
||
76 | $blocksadmin->cloneBlock($bid); |
||
77 | } |
||
78 | |||
79 | if ('delete' === $op) { |
||
80 | if (1 === $ok) { |
||
81 | // if (!$GLOBALS['xoopsSecurity']->check()) { |
||
82 | // redirect_header($helper->url('admin/blocksadmin.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
83 | // } |
||
84 | $blocksadmin->deleteBlock($bid); |
||
85 | } else { |
||
86 | // xoops_cp_header(); |
||
87 | xoops_confirm(['ok' => 1, 'op' => 'delete', 'bid' => $bid], 'blocksadmin.php', constant('CO_' . $moduleDirNameUpper . '_' . 'DELETE_BLOCK_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
||
88 | xoops_cp_footer(); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | if ('edit' === $op) { |
||
93 | $blocksadmin->editBlock($bid); |
||
94 | } |
||
95 | |||
96 | if ('edit_ok' === $op) { |
||
97 | $blocksadmin->updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
||
98 | } |
||
99 | |||
100 | if ('clone_ok' === $op) { |
||
101 | $blocksadmin->isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
||
102 | } |
||
103 | } |
||
104 | |||
105 | if ('order' === $op) { |
||
106 | $bid = Request::getArray('bid', []); |
||
107 | |||
108 | $title = Request::getArray('title', [], 'POST'); |
||
109 | $side = Request::getArray('side', [], 'POST'); |
||
110 | $weight = Request::getArray('weight', [], 'POST'); |
||
111 | $visible = Request::getArray('visible', [], 'POST'); |
||
112 | $bcachetime = Request::getArray('bcachetime', [], 'POST'); |
||
113 | |||
114 | $oldtitle = Request::getArray('oldtitle', [], 'POST'); |
||
115 | $oldside = Request::getArray('oldside', [], 'POST'); |
||
116 | $oldweight = Request::getArray('oldweight', [], 'POST'); |
||
117 | $oldvisible = Request::getArray('oldvisible', [], 'POST'); |
||
118 | $oldgroups = Request::getArray('oldgroups', [], 'POST'); |
||
119 | $oldbcachetime = Request::getArray('oldcachetime', [], 'POST'); |
||
120 | |||
121 | $blocksadmin->orderBlock( |
||
122 | $bid, |
||
123 | $oldtitle, |
||
124 | $oldside, |
||
125 | $oldweight, |
||
126 | $oldvisible, |
||
127 | $oldgroups, |
||
128 | $oldbcachetime, |
||
129 | $title, |
||
130 | $weight, |
||
131 | $visible, |
||
132 | $side, |
||
133 | $bcachetime, |
||
134 | $groups, |
||
135 | $bmodule = null |
||
136 | ); |
||
137 | } |
||
138 | } else { |
||
139 | echo constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'); |
||
140 | } |
||
141 | |||
142 | require __DIR__ . '/admin_footer.php'; |
||
143 |