| Conditions | 5 |
| Paths | 4 |
| Total Lines | 53 |
| Code Lines | 46 |
| 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 namespace XoopsModules\Tdmcreate\Files\Admin; |
||
| 85 | private function getAdminHeader($moduleDirname) |
||
| 86 | { |
||
| 87 | $ucfModuleDirname = ucfirst($moduleDirname); |
||
| 88 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 89 | $table = $this->getTable(); |
||
| 90 | $tables = $this->getTables(); |
||
| 91 | $ret = $this->phpcode->getPhpCodeIncludeDir('dirname(dirname(dirname(__DIR__)))', 'include/cp_header'); |
||
| 92 | $ret .= $this->phpcode->getPhpCodeIncludeDir('dirname(__DIR__)', 'include/common', true); |
||
| 93 | $sysicons16 = $this->xc->getXcGetInfo('', 'sysicons16', true); |
||
| 94 | $sysicons32 = $this->xc->getXcGetInfo('', 'sysicons32', true); |
||
| 95 | $dirmoduleadmin = $this->xc->getXcGetInfo('', 'dirmoduleadmin', true); |
||
| 96 | $modicons16 = $this->xc->getXcGetInfo('', 'modicons16', true); |
||
| 97 | $modicons32 = $this->xc->getXcGetInfo('', 'modicons32', true); |
||
| 98 | $ret .= $this->xc->getXcEqualsOperator('$sysPathIcon16 ', "'../' . {$sysicons16}"); |
||
| 99 | $ret .= $this->xc->getXcEqualsOperator('$sysPathIcon32 ', "'../' . {$sysicons32}"); |
||
| 100 | $ret .= $this->xc->getXcEqualsOperator('$pathModuleAdmin ', $dirmoduleadmin); |
||
| 101 | $ret .= $this->xc->getXcEqualsOperator('$modPathIcon16 ', $modicons16); |
||
| 102 | $ret .= $this->xc->getXcEqualsOperator('$modPathIcon32 ', $modicons32); |
||
| 103 | if (is_object($table) && '' != $table->getVar('table_name')) { |
||
| 104 | $ret .= $this->phpcode->getPhpCodeCommentLine('Get instance of module'); |
||
| 105 | $ret .= $this->xc->getXcEqualsOperator("\${$moduleDirname}", "{$ucfModuleDirname}Helper::getInstance()"); |
||
| 106 | } |
||
| 107 | if (is_array($tables)) { |
||
| 108 | foreach (array_keys($tables) as $i) { |
||
| 109 | $tableName = $tables[$i]->getVar('table_name'); |
||
| 110 | $ret .= $this->xc->getXcEqualsOperator("\${$tableName}Handler", "\${$moduleDirname}->getHandler('{$tableName}')", null, true); |
||
| 111 | } |
||
| 112 | } |
||
| 113 | $ret .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()', null, false); |
||
| 114 | $ret .= $this->phpcode->getPhpCodeCommentLine(); |
||
| 115 | $template = $this->phpcode->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/template', true, false, 'include', "\t"); |
||
| 116 | $template .= $this->xc->getXcEqualsOperator('$xoopsTpl', 'new \XoopsTpl()', null, false, "\t"); |
||
| 117 | $ret .= $this->phpcode->getPhpCodeConditions('!isset($xoopsTpl)', ' || ', '!is_object($xoopsTpl)', $template, false); |
||
| 118 | $ret .= $this->phpcode->getPhpCodeCommentLine('System icons path'); |
||
| 119 | $ret .= $this->xc->getXcTplAssign('sysPathIcon16', '$sysPathIcon16'); |
||
| 120 | $ret .= $this->xc->getXcTplAssign('sysPathIcon32', '$sysPathIcon32'); |
||
| 121 | $ret .= $this->xc->getXcTplAssign('modPathIcon16', '$modPathIcon16'); |
||
| 122 | $ret .= $this->xc->getXcTplAssign('modPathIcon32', '$modPathIcon32'); |
||
| 123 | $ret .= $this->phpcode->getPhpCodeCommentLine('Load languages'); |
||
| 124 | $ret .= $this->xc->getXcLoadLanguage('admin'); |
||
| 125 | $ret .= $this->xc->getXcLoadLanguage('modinfo'); |
||
| 126 | $ret .= $this->phpcode->getPhpCodeCommentLine('Local admin menu class'); |
||
| 127 | $xoopsPathCond = $this->xc->getXcPath('$pathModuleAdmin', 'moduleadmin', true); |
||
| 128 | $fileExists = $this->phpcode->getPhpCodeFileExists($xoopsPathCond); |
||
| 129 | $moduleadmin = $this->phpcode->getPhpCodeIncludeDir($xoopsPathCond, '', true, true, 'include', "\t"); |
||
| 130 | $redirectHeader = $this->xc->getXcRedirectHeader('../../../admin.php', '', '5', '_AM_MODULEADMIN_MISSING', true, "\t"); |
||
| 131 | |||
| 132 | $ret .= $this->phpcode->getPhpCodeConditions($fileExists, '', '', $moduleadmin, $redirectHeader); |
||
| 133 | $ret .= $this->xc->getXcCPHeader(); |
||
| 134 | $ret .= $this->xc->getXcEqualsOperator('$adminObject', '\Xmf\Module\Admin::getInstance()'); |
||
| 135 | $ret .= $this->getSimpleString("\$style = {$stuModuleDirname}_URL . '/assets/css/admin/style.css';"); |
||
| 136 | |||
| 137 | return $ret; |
||
| 138 | } |
||
| 158 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..