Conditions | 10 |
Paths | 384 |
Total Lines | 59 |
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 |
||
74 | function apcal_coming_schedule_edit($options) |
||
75 | { |
||
76 | global $xoopsDB, $xoopsConfig; |
||
77 | |||
78 | $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0]; |
||
79 | $maxitem = empty($options[1]) ? 10 : (int)$options[1]; |
||
80 | $now_cid = empty($options[2]) ? 0 : (int)$options[2]; |
||
81 | $untildays = empty($options[4]) ? 0 : (int)$options[4]; |
||
82 | $showPictures = empty($options[3]) ? 0 : (int)$options[3]; |
||
83 | |||
84 | // setting physical & virtual paths |
||
85 | $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName"; |
||
86 | $mod_url = XOOPS_URL . "/modules/$moduleDirName"; |
||
87 | |||
88 | // defining class of APCal |
||
89 | require_once "$mod_path/class/APCal.php"; |
||
90 | require_once "$mod_path/class/APCal_xoops.php"; |
||
91 | |||
92 | // creating an instance of APCal |
||
93 | $cal = new APCal_xoops(date('Y-n-j'), $xoopsConfig['language'], true); |
||
94 | $cal->use_server_TZ = true; |
||
95 | |||
96 | // setting properties of APCal |
||
97 | $cal->conn = $GLOBALS['xoopsDB']->conn; |
||
98 | include "$mod_path/include/read_configs.php"; |
||
99 | $cal->base_url = $mod_url; |
||
100 | $cal->base_path = $mod_path; |
||
101 | $cal->images_url = "$mod_url/assets/images/$skin_folder"; |
||
102 | $cal->images_path = "$mod_path/assets/images/$skin_folder"; |
||
103 | |||
104 | $ret = "<input type='hidden' name='options[0]' value='$moduleDirName' />\n"; |
||
105 | |||
106 | // ɽ¼¨¸Ä¿ô |
||
107 | $ret .= _MB_APCAL_MAXITEMS . ':'; |
||
108 | $ret .= "<input type='text' size='4' name='options[1]' value='$maxitem' style='text-align:right;' /><br>\n"; |
||
109 | |||
110 | // ¥«¥Æ¥´¥ê¡¼ÁªÂò¥Ü¥Ã¥¯¥¹¤ÎÀ¸À® |
||
111 | $ret .= _MB_APCAL_CATSEL . ':'; |
||
112 | $ret .= "<select name='options[2]'>\n<option value='0'>" . _ALL . "</option>\n"; |
||
113 | foreach ($cal->categories as $cid => $cat) { |
||
114 | $selected = $now_cid == $cid ? 'selected' : ''; |
||
115 | $depth_desc = str_repeat('-', (int)$cat->cat_depth); |
||
116 | $cat_title4show = $cal->text_sanitizer_for_show($cat->cat_title); |
||
117 | $ret .= "\t<option value='$cid' $selected>$depth_desc $cat_title4show</option>\n"; |
||
118 | } |
||
119 | $ret .= "</select><br>\n"; |
||
120 | |||
121 | // ¥µ¥Ö¥«¥Æ¥´¥ê¡¼É½¼¨¤Î¼ÂÁõ¤Ï¤Þ¤À¤Þ¤ÀÀè¡Ê°ì±þͽÌó¤À¤±¤·¤Æ¤ª¤¯¡Ë |
||
122 | //$ret .= "<input type='hidden' name='options[3]' value='0' />\n" ; |
||
123 | |||
124 | $ret .= _MB_APCAL_SHOWPICTURES . ': '; |
||
125 | $ret .= _MB_APCAL_YES . " <input type='radio' name='options[3]' value='1'" . ($showPictures == 1 ? 'checked' : '') . " style='text-align:right;' /> "; |
||
126 | $ret .= _MB_APCAL_NO . " <input type='radio' name='options[3]' value='0'" . ($showPictures == 0 ? 'checked' : '') . " style='text-align:right;' /><br>\n"; |
||
127 | |||
128 | // ɽ¼¨¾å¸ÂÆü¿ô |
||
129 | $ret .= sprintf(_MB_APCAL_UNTILDAYS, "<input type='text' size='4' name='options[4]' value='$untildays' style='text-align:right;' />") . "<br>\n"; |
||
130 | |||
131 | return $ret; |
||
132 | } |
||
133 | } |
||
134 |
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.