| Conditions | 12 |
| Paths | 228 |
| Total Lines | 42 |
| Code Lines | 30 |
| 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 namespace XoopsModules\Tdmcreate\Form; |
||
| 31 | public function render() |
||
| 32 | { |
||
| 33 | $ret = ''; |
||
| 34 | $ele_name = $this->getName(); |
||
| 35 | $ele_title = $this->getTitle(); |
||
| 36 | $ele_value = $this->getValue(); |
||
| 37 | $ele_options = $this->getOptions(); |
||
| 38 | $ele_extra = $this->getExtra(); |
||
| 39 | $ele_delimeter = empty($this->columns) ? $this->getDelimeter() : ''; |
||
| 40 | if (!empty($this->columns)) { |
||
| 41 | $ret .= '<table class="table table-bordered"><tr>'; |
||
| 42 | } |
||
| 43 | $i = 0; |
||
| 44 | $id_ele = 0; |
||
| 45 | foreach ($ele_options as $value => $name) { |
||
| 46 | ++$id_ele; |
||
| 47 | if (!empty($this->columns)) { |
||
| 48 | if (0 == $i % $this->columns) { |
||
| 49 | $ret .= '<tr>'; |
||
| 50 | } |
||
| 51 | $ret .= '<td class="radio">'; |
||
| 52 | } |
||
| 53 | $ret .= '<input type="radio" name="'.$ele_name.'" id="'.$ele_name.'['.$value.']'.$id_ele.'" title = "'.htmlspecialchars($ele_title, ENT_QUOTES).'" value="'.htmlspecialchars($value, ENT_QUOTES).'"'; |
||
| 54 | if (isset($ele_value) && $value == $ele_value) { |
||
| 55 | $ret .= ' checked'; |
||
| 56 | } |
||
| 57 | $ret .= $ele_extra.' />'."<label name='xolb_{$ele_name}' for='".$ele_name.'['.$value.']'.$id_ele."'><span><span></span></span>".$name.'</label>'.$ele_delimeter; |
||
| 58 | if (!empty($this->columns)) { |
||
| 59 | $ret .= '</td>'; |
||
| 60 | if (0 == ++$i % $this->columns) { |
||
| 61 | $ret .= '</tr>'; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | if (!empty($this->columns)) { |
||
| 66 | if ($span = $i % $this->columns) { |
||
| 67 | $ret .= '<td colspan="'.($this->columns - $span).'"></td></tr>'; |
||
| 68 | } |
||
| 69 | $ret .= '</table>'; |
||
| 70 | } |
||
| 71 | |||
| 72 | return $ret; |
||
| 73 | } |
||
| 75 |