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