| Conditions | 9 |
| Paths | 26 |
| Total Lines | 67 |
| Code Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 2 | Features | 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 |
||
| 128 | private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields) |
||
| 129 | { |
||
| 130 | $hc = TDMCreateHtmlSmartyCodes::getInstance(); |
||
| 131 | $td = ''; |
||
| 132 | if (1 == $tableAutoincrement) { |
||
| 133 | $double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 134 | $td .= $hc->getHtmlTableData($double, 'center'); |
||
| 135 | } |
||
| 136 | foreach (array_keys($fields) as $f) { |
||
| 137 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 138 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 139 | $rpFieldName = $this->getRightString($fieldName); |
||
| 140 | if (0 == $f) { |
||
| 141 | $fieldId = $fieldName; |
||
| 142 | } |
||
| 143 | if (1 == $fields[$f]->getVar('field_inlist')) { |
||
| 144 | switch ($fieldElement) { |
||
| 145 | case 9: |
||
| 146 | // This is to be reviewed, as it was initially to style = "backgroung-color: #" |
||
| 147 | // Now with HTML5 is not supported inline style in the parameters of the HTML tag |
||
| 148 | // Old code was <span style="background-color: #<{\$list.{$rpFieldName}}>;">... |
||
| 149 | $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 150 | $span = $hc->getHtmlTag('span', array(), $double); |
||
| 151 | $td .= $hc->getHtmlTag('td', array('class' => 'center'), $span); |
||
| 152 | /*$ret .= <<<EOT |
||
| 153 | <td class="center"><span style="background-color: #<{\$list.{$rpFieldName}}>;"> </span></td>\n |
||
| 154 | EOT;*/ |
||
| 155 | break; |
||
| 156 | case 10: |
||
| 157 | $src = $hc->getSmartyNoSimbol('xoModuleIcons32'); |
||
| 158 | $src .= $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 159 | $img = $hc->getHtmlTag('img', array('src' => $src, 'alt' => $tableName), '', true, false); |
||
| 160 | $td .= $hc->getHtmlTag('td', array('class' => 'center'), "\n\t".$img); |
||
| 161 | break; |
||
| 162 | case 13: |
||
| 163 | $single = $hc->getSmartySingleVar($moduleDirname.'_upload_url'); |
||
| 164 | $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 165 | $img = $hc->getHtmlTag('img', array('src' => $single."/images/{$tableName}/".$double, 'alt' => $tableName, 'style' => 'max-width:100px'), '', true, false); |
||
| 166 | $td .= $hc->getHtmlTag('td', array('class' => 'center'), $img, false, false, "\t\t"); |
||
| 167 | break; |
||
| 168 | default: |
||
| 169 | if (0 != $f) { |
||
| 170 | $double = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
| 171 | $td .= $hc->getHtmlTag('td', array('class' => 'center'), $double); |
||
| 172 | } |
||
| 173 | break; |
||
| 174 | } |
||
| 175 | } |
||
| 176 | } |
||
| 177 | $lang = $hc->getSmartyConst('', '_EDIT'); |
||
| 178 | $double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 179 | $src = $hc->getSmartyNoSimbol('xoModuleIcons16 edit.png'); |
||
| 180 | $img = $hc->getHtmlTag('img', array('src' => $src, 'alt' => $tableName), '', true, false); |
||
| 181 | $anchor = $hc->getHtmlTag('a', array('href' => $tableName.".php?op=edit&{$fieldId}=".$double, 'title' => $lang), "\n\t".$img); |
||
| 182 | $lang = $hc->getSmartyConst('', '_DELETE'); |
||
| 183 | $double = $hc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
| 184 | $src = $hc->getSmartyNoSimbol('xoModuleIcons16 delete.png'); |
||
| 185 | $img = $hc->getHtmlTag('img', array('src' => $src, 'alt' => $tableName), '', true, false); |
||
| 186 | $anchor .= $hc->getHtmlTag('a', array('href' => $tableName.".php?op=delete&{$fieldId}=".$double, 'title' => $lang), "\n\t".$img); |
||
| 187 | $td .= $hc->getHtmlTag('td', array('class' => 'center width5'), "\n".$anchor); |
||
| 188 | $cycle = $hc->getSmartyNoSimbol('cycle values=\'odd, even\''); |
||
| 189 | $tr = $hc->getHtmlTag('tr', array('class' => $cycle), $td); |
||
| 190 | $foreach = $hc->getSmartyForeach($tableSoleName, $tableName.'_list', $tr); |
||
| 191 | $tbody = $hc->getHtmlTag('tbody', array(), $foreach); |
||
| 192 | |||
| 193 | return $hc->getSmartyConditions($tableName.'_count', '', '', $tbody); |
||
| 194 | } |
||
| 195 | |||
| 280 |
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.