Conditions | 12 |
Paths | 22 |
Total Lines | 66 |
Code Lines | 55 |
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 |
||
140 | private function getTemplatesUserPrintTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields) |
||
141 | { |
||
142 | $td = ''; |
||
143 | if (1 == $tableAutoincrement) { |
||
144 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); |
||
145 | $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t"); |
||
146 | } |
||
147 | foreach (\array_keys($fields) as $f) { |
||
148 | $fieldName = $fields[$f]->getVar('field_name'); |
||
149 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
150 | $rpFieldName = $this->getRightString($fieldName); |
||
151 | if (1 == $fields[$f]->getVar('field_user')) { |
||
152 | switch ($fieldElement) { |
||
153 | case 3: |
||
154 | case 4: |
||
155 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short'); |
||
156 | $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t"); |
||
157 | break; |
||
158 | case 5: |
||
159 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
160 | $src = $this->sc->getSmartyNoSimbol('xoModuleIcons16') . $double . '.png'; |
||
161 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true,'',''); |
||
162 | $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t"); |
||
163 | break; |
||
164 | case 9: |
||
165 | // This is to be reviewed, as it was initially to style = "backgroung-color: #" |
||
166 | // Now with HTML5 is not supported inline style in the parameters of the HTML tag |
||
167 | // Old code was <span style="background-color: #<{\$list.{$rpFieldName}}>;">... |
||
168 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
169 | $color = "<span style='background-color:{$double};'> </span>"; |
||
170 | $td .= $this->hc->getHtmlTableData($color, 'center', '',"\t\t\t"); |
||
171 | break; |
||
172 | case 10: |
||
173 | $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32'); |
||
174 | $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
175 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true,'',''); |
||
176 | $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t"); |
||
177 | break; |
||
178 | case 13: |
||
179 | $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
||
180 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
181 | $img = $this->hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName, 'style' => 'max-width:100px'], '', true, '', ''); |
||
182 | $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t"); |
||
183 | break; |
||
184 | case 16: |
||
185 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
186 | $src = $this->sc->getSmartyNoSimbol('$modPathIcon16') . 'status' . $double . '.png'; |
||
187 | $imgAlt = $this->sc->getSmartyDoubleVar($tableSoleName, 'status_text'); |
||
188 | $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $imgAlt, 'title' => $imgAlt], '', true,'',''); |
||
189 | $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t"); |
||
190 | break; |
||
191 | default: |
||
192 | if (0 != $f) { |
||
193 | $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
194 | $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t"); |
||
195 | } |
||
196 | break; |
||
197 | } |
||
198 | } |
||
199 | } |
||
200 | $cycle = $this->sc->getSmartyNoSimbol('cycle values=\'odd, even\''); |
||
201 | $tr = $this->hc->getHtmlTableRow($td, $cycle, "\t\t"); |
||
202 | $foreach = $this->sc->getSmartyForeach($tableSoleName, $tableName . '_list', $tr, '','', "\t\t"); |
||
203 | $tbody = $this->hc->getHtmlTableTbody($foreach,'' , "\t"); |
||
204 | |||
205 | return $tbody; |
||
206 | } |
||
278 |