| Conditions | 8 |
| Paths | 16 |
| Total Lines | 57 |
| 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; |
||
| 76 | private function getAdminIndex($module) |
||
| 77 | { |
||
| 78 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 79 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 80 | $axc = Tdmcreate\Files\Admin\AdminXoopsCode::getInstance(); |
||
| 81 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 82 | $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
||
| 83 | $language = $this->getLanguage($moduleDirname, 'AM'); |
||
| 84 | $languageThereAre = $this->getLanguage($moduleDirname, 'AM', 'THEREARE_'); |
||
| 85 | $ret = $this->getInclude(); |
||
| 86 | $ret .= $pc->getPhpCodeCommentLine('Count elements'); |
||
| 87 | $tableName = null; |
||
| 88 | foreach (array_keys($tables) as $i) { |
||
| 89 | $tableName = $tables[$i]->getVar('table_name'); |
||
| 90 | $ucfTableName = ucfirst($tableName); |
||
| 91 | $ret .= $xc->getXcEqualsOperator("\$count{$ucfTableName}", "\${$tableName}Handler->getCount()"); |
||
| 92 | } |
||
| 93 | $ret .= $pc->getPhpCodeCommentLine('Template Index'); |
||
| 94 | $ret .= $axc->getAdminTemplateMain((string)$moduleDirname, 'index'); |
||
| 95 | $ret .= $pc->getPhpCodeCommentLine('InfoBox Statistics'); |
||
| 96 | $ret .= $axc->getAxcAddInfoBox($language . 'STATISTICS'); |
||
| 97 | $ret .= $pc->getPhpCodeCommentLine('Info elements'); |
||
| 98 | foreach (array_keys($tables) as $i) { |
||
| 99 | $tableName = $tables[$i]->getVar('table_name'); |
||
| 100 | $tableInstall[] = $tables[$i]->getVar('table_install'); |
||
| 101 | $stuTableName = $languageThereAre . mb_strtoupper($tableName); |
||
| 102 | $ucfTableName = ucfirst($tableName); |
||
| 103 | $ret .= $axc->getAxcAddInfoBoxLine($language . 'STATISTICS', $stuTableName, "\$count{$ucfTableName}"); |
||
| 104 | } |
||
| 105 | |||
| 106 | if (null === $tableName) { |
||
| 107 | $ret .= $axc->getAxcAddInfoBoxLine($language . 'STATISTICS', 'No statistics', '0'); |
||
| 108 | } |
||
| 109 | if (is_array($tables) && in_array(1, $tableInstall)) { |
||
|
|
|||
| 110 | $ret .= $pc->getPhpCodeCommentLine('Upload Folders'); |
||
| 111 | $ret .= $this->getSimpleString('$folder = array('); |
||
| 112 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 113 | $ret .= $this->getSimpleString("\t{$stuModuleDirname}_UPLOAD_PATH,"); |
||
| 114 | foreach (array_keys($tables) as $i) { |
||
| 115 | $tableName = $tables[$i]->getVar('table_name'); |
||
| 116 | if (1 == $tables[$i]->getVar('table_install')) { |
||
| 117 | $ret .= $this->getSimpleString("\t{$stuModuleDirname}_UPLOAD_PATH . '/{$tableName}/',"); |
||
| 118 | } |
||
| 119 | } |
||
| 120 | $ret .= $this->getSimpleString(');'); |
||
| 121 | $ret .= $pc->getPhpCodeCommentLine('Uploads Folders Created'); |
||
| 122 | $boxLine = $axc->getAxcAddConfigBoxLine('$folder[$i]', 'folder', '', "\t"); |
||
| 123 | $boxLine .= $axc->getAxcAddConfigBoxLine("array(\$folder[\$i], '777')", 'chmod', '', "\t"); |
||
| 124 | $ret .= $pc->getPhpCodeForeach('folder', true, false, 'i', $boxLine, '') . PHP_EOL; |
||
| 125 | } |
||
| 126 | $ret .= $pc->getPhpCodeCommentLine('Render Index'); |
||
| 127 | $ret .= $xc->getXcTplAssign('navigation', "\$adminObject->displayNavigation('index.php')"); |
||
| 128 | $ret .= $xc->getXcTplAssign('index', '$adminObject->displayIndex()'); |
||
| 129 | |||
| 130 | $ret .= $this->getInclude('footer'); |
||
| 131 | |||
| 132 | return $ret; |
||
| 133 | } |
||
| 153 |