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