| Conditions | 15 |
| Paths | 160 |
| Total Lines | 77 |
| Code Lines | 63 |
| 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 |
||
| 88 | private function getTemplatesUserPagesListPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) |
||
| 89 | { |
||
| 90 | $hc = TDMCreateHtmlSmartyCodes::getInstance(); |
||
| 91 | $fields = $this->getTableFields($tableMid, $tableId); |
||
| 92 | $ret = ''; |
||
| 93 | $retNumb = ''; |
||
| 94 | foreach (array_keys($fields) as $f) { |
||
| 95 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 96 | if (1 == $fields[$f]->getVar('field_user')) { |
||
| 97 | if (1 == $fields[$f]->getVar('field_thead')) { |
||
| 98 | switch ($fieldElement) { |
||
| 99 | default: |
||
| 100 | case 2: |
||
| 101 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 102 | $rpFieldName = $this->getRightString($fieldName); |
||
| 103 | $doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 104 | $retNumb = $hc->getHtmlHNumb($doubleVar, '3', 'panel-title'); |
||
| 105 | break; |
||
| 106 | } |
||
| 107 | } |
||
| 108 | } |
||
| 109 | } |
||
| 110 | $ret .= $hc->getHtmlDiv($retNumb, 'panel-heading').PHP_EOL; |
||
| 111 | $retElem = ''; |
||
| 112 | foreach (array_keys($fields) as $f) { |
||
| 113 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 114 | if (1 == $fields[$f]->getVar('field_user')) { |
||
| 115 | if (1 == $fields[$f]->getVar('field_tbody')) { |
||
| 116 | switch ($fieldElement) { |
||
| 117 | default: |
||
| 118 | case 3: |
||
| 119 | case 4: |
||
| 120 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 121 | $rpFieldName = $this->getRightString($fieldName); |
||
| 122 | $doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 123 | $retElem .= $hc->getHtmlSpan($doubleVar, 'col-sm-9 justify').PHP_EOL; |
||
| 124 | break; |
||
| 125 | case 10: |
||
| 126 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 127 | $rpFieldName = $this->getRightString($fieldName); |
||
| 128 | $singleVar = $hc->getSmartySingleVar('xoops_icons32_url'); |
||
| 129 | $doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 130 | $img = $hc->getHtmlImage($singleVar.'/'.$doubleVar, "{$tableName}"); |
||
| 131 | $retElem .= $hc->getHtmlSpan($img, 'col-sm-3').PHP_EOL; |
||
| 132 | unset($img); |
||
| 133 | break; |
||
| 134 | case 13: |
||
| 135 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 136 | $rpFieldName = $this->getRightString($fieldName); |
||
| 137 | $singleVar = $hc->getSmartySingleVar($moduleDirname.'_upload_url'); |
||
| 138 | $doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 139 | $img = $hc->getHtmlImage($singleVar."/images/{$tableName}/".$doubleVar, "{$tableName}"); |
||
| 140 | $retElem .= $hc->getHtmlSpan($img, 'col-sm-3').PHP_EOL; |
||
| 141 | unset($img); |
||
| 142 | break; |
||
| 143 | } |
||
| 144 | } |
||
| 145 | } |
||
| 146 | } |
||
| 147 | $ret .= $hc->getHtmlDiv($retElem, 'panel-body').PHP_EOL; |
||
| 148 | $retFoot = ''; |
||
| 149 | foreach (array_keys($fields) as $f) { |
||
| 150 | if (1 == $fields[$f]->getVar('field_user')) { |
||
| 151 | if (1 == $fields[$f]->getVar('field_tfoot')) { |
||
| 152 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 153 | $rpFieldName = $this->getRightString($fieldName); |
||
| 154 | $langConst = strtoupper($tableSoleName).'_'.strtoupper($rpFieldName); |
||
| 155 | $lang = $hc->getSmartyConst($language, $langConst); |
||
| 156 | $doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 157 | $retFoot .= $hc->getHtmlSpan($lang.': '.$doubleVar, 'block-pie justify').PHP_EOL; |
||
| 158 | } |
||
| 159 | } |
||
| 160 | } |
||
| 161 | $ret .= $hc->getHtmlDiv($retFoot, 'panel-foot').PHP_EOL; |
||
| 162 | |||
| 163 | return $ret; |
||
| 164 | } |
||
| 165 | |||
| 203 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.