| Conditions | 10 |
| Paths | 3 |
| Total Lines | 56 |
| Code Lines | 30 |
| 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 declare(strict_types=1); |
||
| 113 | function runReport(string $reportName) |
||
| 114 | { |
||
| 115 | global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xhelp_module_header, $paramVals; |
||
| 116 | |||
| 117 | // $classname = 'xhelp' . $reportName . 'Report'; |
||
| 118 | // require_once XHELP_REPORT_PATH . '/' . $reportName . '.php'; |
||
| 119 | // if( strpos($filename,'Report') !== false ) { |
||
| 120 | // $classname = 'XoopsModules\Xhelp\Reports\\' . \ucfirst($reportName). 'Report'; |
||
| 121 | $classname = 'XoopsModules\Xhelp\Reports\\' . \ucfirst($reportName); |
||
| 122 | if (!\class_exists($classname)) { |
||
| 123 | throw new \RuntimeException("Class '$classname' not found"); |
||
| 124 | } |
||
| 125 | $report = new $classname(); |
||
| 126 | |||
| 127 | // Get any parameters for report |
||
| 128 | $reportParams = $report->getParams(); |
||
| 129 | |||
| 130 | // Fill reportParameters with updated information |
||
| 131 | if (is_countable($reportParams) && count($reportParams) > 0) { |
||
| 132 | foreach ($reportParams as $param) { |
||
| 133 | if (isset($_REQUEST[$param->fieldname])) { |
||
| 134 | if (XHELP_CONTROL_DATETIME == $param->controltype) { |
||
| 135 | $param->value = strtotime($_REQUEST[$param->fieldname]); |
||
| 136 | } else { |
||
| 137 | $param->value = $_REQUEST[$param->fieldname]; |
||
| 138 | } |
||
| 139 | } else { |
||
| 140 | if (isset($paramVals[$param->fieldname])) { |
||
| 141 | if (XHELP_CONTROL_DATETIME == $param->controltype) { |
||
| 142 | $param->value = strtotime($paramVals[$param->fieldname]); |
||
| 143 | } else { |
||
| 144 | if (is_array($paramVals[$param->fieldname])) { |
||
| 145 | $param->values = $paramVals[$param->fieldname]; |
||
| 146 | } else { |
||
| 147 | $param->value = $paramVals[$param->fieldname]; |
||
| 148 | } |
||
| 149 | } |
||
| 150 | } |
||
| 151 | } |
||
| 152 | } |
||
| 153 | $report->extraWhere = $report->makeWhere($reportParams); |
||
| 154 | } |
||
| 155 | |||
| 156 | //$GLOBALS['xoopsOption']['template_main'] = 'xhelp_report.tpl'; // Set template |
||
| 157 | require_once XOOPS_ROOT_PATH . '/header.php'; // Include page header |
||
| 158 | |||
| 159 | generateHeader($report); |
||
| 160 | |||
| 161 | /** @var \XoopsModules\Xhelp\ReportRenderer\HtmlReportRenderer $oRenderer */ |
||
| 162 | $oRenderer = Xhelp\ReportRendererFactory::getRenderer('html', $report); |
||
|
|
|||
| 163 | echo $oRenderer->render(); |
||
| 164 | |||
| 165 | $xoopsTpl->assign('xhelp_imagePath', XHELP_IMAGE_URL . '/'); |
||
| 166 | $xoopsTpl->assign('xoops_module_header', $xhelp_module_header); |
||
| 167 | |||
| 168 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 169 | } |
||
| 228 |