| Conditions | 6 |
| Paths | 16 |
| Total Lines | 55 |
| 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 |
||
| 28 | function apcal_map_show($options) |
||
| 29 | { |
||
| 30 | global $xoopsConfig, $xoopsDB; |
||
| 31 | |||
| 32 | $original_level = error_reporting(E_ALL ^ E_NOTICE); |
||
| 33 | |||
| 34 | $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0]; |
||
| 35 | |||
| 36 | // setting physical & virtual paths |
||
| 37 | $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName"; |
||
| 38 | $mod_url = XOOPS_URL . "/modules/$moduleDirName"; |
||
| 39 | |||
| 40 | // defining class of APCal |
||
| 41 | if (!class_exists('APCal_xoops')) { |
||
| 42 | require_once "$mod_path/class/APCal.php"; |
||
| 43 | require_once "$mod_path/class/APCal_xoops.php"; |
||
| 44 | } |
||
| 45 | |||
| 46 | // creating an instance of APCal |
||
| 47 | $cal = new APCal_xoops('', $xoopsConfig['language'], true); |
||
| 48 | |||
| 49 | // ignoring cid from GET |
||
| 50 | $cal->now_cid = 0; |
||
| 51 | |||
| 52 | // setting properties of APCal |
||
| 53 | $cal->conn = $GLOBALS['xoopsDB']->conn; |
||
| 54 | include "$mod_path/include/read_configs.php"; |
||
| 55 | $cal->base_url = $mod_url; |
||
| 56 | $cal->base_path = $mod_path; |
||
| 57 | $cal->images_url = "$mod_url/assets/images/$skin_folder"; |
||
|
|
|||
| 58 | $cal->images_path = "$mod_path/assets/images/$skin_folder"; |
||
| 59 | |||
| 60 | $cal->get_monthly_html("$mod_url"); |
||
| 61 | |||
| 62 | if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
||
| 63 | } else { |
||
| 64 | $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
||
| 65 | } |
||
| 66 | |||
| 67 | $block = array(); |
||
| 68 | if (is_array($cal->gmPoints) && !empty($cal->gmPoints)) { |
||
| 69 | $tpl = new XoopsTpl(); |
||
| 70 | $tpl->assign('GMlatitude', $cal->gmlat); |
||
| 71 | $tpl->assign('GMlongitude', $cal->gmlng); |
||
| 72 | $tpl->assign('GMzoom', $cal->gmzoom); |
||
| 73 | $tpl->assign('GMheight', $cal->gmheight . 'px'); |
||
| 74 | $tpl->assign('GMPoints', $cal->gmPoints); |
||
| 75 | $tpl->assign('api_key', $moduleHelper->getConfig('apcal_mapsapi')); |
||
| 76 | $block['map'] = $tpl->fetch(XOOPS_ROOT_PATH . '/modules/apcal/templates/apcal_googlemap.tpl'); |
||
| 77 | } |
||
| 78 | |||
| 79 | error_reporting($original_level); |
||
| 80 | |||
| 81 | return $block; |
||
| 82 | } |
||
| 83 | |||
| 93 |
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.