Conditions | 7 |
Paths | 48 |
Total Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
90 | function apcal_after_schedule_edit($options) |
||
91 | { |
||
92 | global $xoopsDB, $xoopsConfig; |
||
93 | |||
94 | $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0]; |
||
95 | $maxitem = empty($options[1]) ? 10 : (int)$options[1]; |
||
96 | $now_cid = empty($options[2]) ? 0 : (int)$options[2]; |
||
97 | $untildays = empty($options[4]) ? 0 : (int)$options[4]; |
||
98 | |||
99 | // setting physical & virtual paths |
||
100 | $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName"; |
||
101 | $mod_url = XOOPS_URL . "/modules/$moduleDirName"; |
||
102 | |||
103 | // defining class of APCal |
||
104 | require_once "$mod_path/class/APCal.php"; |
||
105 | require_once "$mod_path/class/APCal_xoops.php"; |
||
106 | |||
107 | // creating an instance of APCal |
||
108 | $cal = new APCal_xoops(date('Y-n-j'), $xoopsConfig['language'], true); |
||
109 | $cal->use_server_TZ = true; |
||
110 | |||
111 | // setting properties of APCal |
||
112 | $cal->conn = $GLOBALS['xoopsDB']->conn; |
||
113 | include "$mod_path/include/read_configs.php"; |
||
114 | $cal->base_url = $mod_url; |
||
115 | $cal->base_path = $mod_path; |
||
116 | $cal->images_url = "$mod_url/assets/images/$skin_folder"; |
||
117 | $cal->images_path = "$mod_path/assets/images/$skin_folder"; |
||
118 | |||
119 | $ret = "<input type='hidden' name='options[0]' value='$moduleDirName' />\n"; |
||
120 | |||
121 | // ɽ¼¨¸Ä¿ô |
||
122 | $ret .= _MB_APCAL_MAXITEMS . ':'; |
||
123 | $ret .= "<input type='text' size='4' name='options[1]' value='$maxitem' style='text-align:right;' /><br>\n"; |
||
124 | |||
125 | // ¥«¥Æ¥´¥ê¡¼ÁªÂò¥Ü¥Ã¥¯¥¹¤ÎÀ¸À® |
||
126 | $ret .= _MB_APCAL_CATSEL . ':'; |
||
127 | $ret .= "<select name='options[2]'>\n<option value='0'>" . _ALL . "</option>\n"; |
||
128 | foreach ($cal->categories as $cid => $cat) { |
||
129 | $selected = $now_cid == $cid ? 'selected' : ''; |
||
130 | $depth_desc = str_repeat('-', (int)$cat->cat_depth); |
||
131 | $cat_title4show = $cal->text_sanitizer_for_show($cat->cat_title); |
||
132 | $ret .= "\t<option value='$cid' $selected>$depth_desc $cat_title4show</option>\n"; |
||
133 | } |
||
134 | $ret .= "</select><br>\n"; |
||
135 | |||
136 | // ¥µ¥Ö¥«¥Æ¥´¥ê¡¼É½¼¨¤Î¼ÂÁõ¤Ï¤Þ¤À¤Þ¤ÀÀè¡Ê°ì±þͽÌó¤À¤±¤·¤Æ¤ª¤¯¡Ë |
||
137 | $ret .= "<input type='hidden' name='options[3]' value='0' />\n"; |
||
138 | |||
139 | // ɽ¼¨¾å¸ÂÆü¿ô |
||
140 | $ret .= sprintf(_MB_APCAL_UNTILDAYS, "<input type='text' size='4' name='options[4]' value='$untildays' style='text-align:right;' />") . "<br>\n"; |
||
141 | |||
142 | return $ret; |
||
143 | } |
||
144 | } |
||
145 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.