Conditions | 10 |
Paths | 54 |
Total Lines | 74 |
Code Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 2 | 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 |
||
27 | function b_wgsitenotice_cookie_reg_show($options) |
||
28 | { |
||
29 | |||
30 | $block = []; |
||
31 | |||
32 | $unique_id = $options[0]; |
||
33 | $block['unique_id'] = $unique_id; |
||
34 | $dataprotect_id = $options[1]; |
||
35 | $cookie_reg_id = $options[2]; |
||
36 | $display_type = $options[3]; |
||
37 | $block['opacity'] = $options[4]; |
||
38 | $block['bg_from'] = $options[5]; |
||
39 | $block['bg_to'] = $options[6]; |
||
40 | $block['color'] = $options[7]; |
||
41 | $block['height'] = $options[8]; |
||
42 | $position = $options[9]; |
||
43 | $type_tpl_id = $options[10]; |
||
44 | |||
45 | \array_shift($options); |
||
46 | \array_shift($options); |
||
47 | \array_shift($options); |
||
48 | \array_shift($options); |
||
49 | \array_shift($options); |
||
50 | \array_shift($options); |
||
51 | \array_shift($options); |
||
52 | \array_shift($options); |
||
53 | \array_shift($options); |
||
54 | \array_shift($options); |
||
55 | |||
56 | //get relevant data |
||
57 | $helper = Helper::getInstance(); |
||
58 | $versionsHandler = $helper->getHandler('Versions'); |
||
59 | |||
60 | $block['infotext'] = \_MB_WGSITENOTICE_COOKIE_REG_INFO; |
||
61 | |||
62 | if ("smarty" == $display_type) { |
||
63 | if ('top' == $position) { |
||
64 | $block['position'] = 'top:0px;position:fixed;left:0px;'; |
||
65 | $block['prependToBody'] = '1'; |
||
66 | } else { |
||
67 | $block['position'] = 'bottom:0px;position:fixed;left:0px;'; |
||
68 | $block['prependToBody'] = '1'; |
||
69 | } |
||
70 | } else { |
||
71 | $block['position'] = ''; |
||
72 | } |
||
73 | |||
74 | if ( $dataprotect_id > 0 || $cookie_reg_id > 0 ) { |
||
75 | $dataprotect_obj = $versionsHandler->get($dataprotect_id); |
||
76 | if (\is_object($dataprotect_obj)) { |
||
77 | $block['dataprotect_id'] = $dataprotect_id; |
||
78 | $block['dataprotect_text'] = $dataprotect_obj->getVar('version_name'); |
||
79 | } |
||
80 | $cookie_reg_obj = $versionsHandler->get($cookie_reg_id); |
||
81 | if (\is_object($cookie_reg_obj)) { |
||
82 | $block['cookie_reg_id'] = $cookie_reg_id; |
||
83 | $block['cookie_reg_text'] = $cookie_reg_obj->getVar('version_name'); |
||
84 | } |
||
85 | $block['seperator'] = ""; |
||
86 | if ( $dataprotect_id > 0 && $cookie_reg_id > 0 ) { |
||
87 | $block['seperator'] = "|"; |
||
88 | } |
||
89 | } |
||
90 | $tplSource = \XOOPS_ROOT_PATH.'/modules/wgsitenotice/templates/blocks/wgsitenotice_block_cookie_reg.tpl'; |
||
91 | |||
92 | if ("smarty" == $display_type) { |
||
93 | //hide block and show in theme.html defined position |
||
94 | $blockTpl = new \XoopsTpl(); |
||
95 | $blockTpl->assign('block', $block); |
||
96 | |||
97 | $GLOBALS['xoopsTpl']->assign( $type_tpl_id, $blockTpl->fetch($tplSource) ); |
||
98 | $block = false; |
||
99 | } |
||
100 | return $block; |
||
101 | } |
||
193 |