Conditions | 8 |
Paths | 96 |
Total Lines | 51 |
Lines | 12 |
Ratio | 23.53 % |
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 |
||
34 | function apcal_after_schedule_show_tpl($options) |
||
35 | { |
||
36 | global $xoopsConfig, $xoopsDB; |
||
37 | |||
38 | $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0]; |
||
39 | $maxitem = empty($options[1]) ? 10 : (int)$options[1]; |
||
40 | $now_cid = empty($options[2]) ? 0 : (int)$options[2]; |
||
41 | $untildays = empty($options[4]) ? 0 : (int)$options[4]; |
||
42 | |||
43 | // setting physical & virtual paths |
||
44 | $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName"; |
||
45 | $mod_url = XOOPS_URL . "/modules/$moduleDirName"; |
||
46 | |||
47 | // defining class of APCal |
||
48 | if (!class_exists('APCal_xoops')) { |
||
49 | require_once "$mod_path/class/APCal.php"; |
||
50 | require_once "$mod_path/class/APCal_xoops.php"; |
||
51 | } |
||
52 | |||
53 | // creating an instance of APCal |
||
54 | $cal = new APCal_xoops('', $xoopsConfig['language'], true); |
||
55 | |||
56 | // cid ¤Ë¤è¤ë¹Ê¤ê¹þ¤ß |
||
57 | $cal->now_cid = $now_cid; |
||
58 | |||
59 | // setting properties of APCal |
||
60 | $cal->conn = $GLOBALS['xoopsDB']->conn; |
||
61 | include "$mod_path/include/read_configs.php"; |
||
62 | $cal->base_url = $mod_url; |
||
63 | $cal->base_path = $mod_path; |
||
64 | $cal->images_url = "$mod_url/assets/images/$skin_folder"; |
||
|
|||
65 | $cal->images_path = "$mod_path/assets/images/$skin_folder"; |
||
66 | |||
67 | // ¥Ö¥í¥Ã¥¯ÇÛÎó¤Î¼«Ê¬¼«¿È¤ò½ñ¤´¹¤¨¤ë title ¤Ë %s ¤ò´Þ¤á¤ë¤³¤È |
||
68 | View Code Duplication | if (substr(XOOPS_VERSION, 6, 3) > 2.0) { |
|
69 | $title_fmt = $GLOBALS['apcal_blockinstance_object']->getVar('title'); |
||
70 | $GLOBALS['apcal_blockinstance_object']->setVar('title', sprintf($title_fmt, sprintf(_APCAL_FMT_MD, $cal->month_short_names[date('n', $cal->unixtime)], |
||
71 | $cal->date_short_names[date('j', $cal->unixtime)]))); |
||
72 | } else { |
||
73 | global $block_arr, $i; |
||
74 | if (is_object($block_arr[$i])) { |
||
75 | $title_fmt = $block_arr[$i]->getVar('title'); |
||
76 | $title = sprintf($title_fmt, sprintf(_APCAL_FMT_MD, $cal->month_short_names[date('n', $cal->unixtime)], $cal->date_short_names[date('j', $cal->unixtime)])); |
||
77 | $block_arr[$i]->setVar('title', $title); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | $block = $cal->get_blockarray_coming_event("$mod_url/index.php", $maxitem, false, $untildays); |
||
82 | |||
83 | return $block; |
||
84 | } |
||
85 | |||
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.