| Conditions | 9 |
| Paths | 30 |
| Total Lines | 54 |
| Code Lines | 38 |
| 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 |
||
| 48 | public function defaultRender() |
||
| 49 | { |
||
| 50 | $xoops = \Xoops::getInstance(); |
||
|
|
|||
| 51 | |||
| 52 | $ret = '<div id="tabs_' . $this->getName() . '">' . "\n"; |
||
| 53 | $ret .= '<ul class="nav nav-tabs">' . "\n"; |
||
| 54 | $active = ' active'; |
||
| 55 | foreach ($this->getElements() as $ele) { |
||
| 56 | if ($ele instanceof Tab) { |
||
| 57 | $ret .= '<li class="nav' . $active . '"><a href="#tab_' . $ele->getName() |
||
| 58 | . '" data-toggle="tab">' . $ele->getCaption() . '</a></li>' . "\n"; |
||
| 59 | $active = ''; |
||
| 60 | } |
||
| 61 | } |
||
| 62 | $ret .= '</ul><br>' . "\n"; |
||
| 63 | |||
| 64 | $hidden = ''; |
||
| 65 | $extras = array(); |
||
| 66 | |||
| 67 | $ret .= '<div class="tab-content">'; |
||
| 68 | $active = ' in active'; |
||
| 69 | |||
| 70 | foreach ($this->getElements() as $ele) { |
||
| 71 | /* @var $ele Element */ |
||
| 72 | if (!$ele->isHidden()) { |
||
| 73 | if (!$ele instanceof Raw) { |
||
| 74 | if ($ele instanceof Tab) { |
||
| 75 | $ret .= '<div class="tab-pane fade' . $active .'" id="tab_'. $ele->getName() . '">'; |
||
| 76 | $ret .= $ele->render(); |
||
| 77 | $ret .= '</div>' . "\n"; |
||
| 78 | $active = ''; |
||
| 79 | } else { |
||
| 80 | $extras[] = $ele; |
||
| 81 | } |
||
| 82 | } else { |
||
| 83 | $ret .= $ele->render(); |
||
| 84 | } |
||
| 85 | } else { |
||
| 86 | $hidden .= $ele->render(); |
||
| 87 | } |
||
| 88 | } |
||
| 89 | if (!empty($extras)) { |
||
| 90 | $tray = new ElementTray('', $this->getJoiner()); |
||
| 91 | foreach ($extras as $extra) { |
||
| 92 | $tray->addElement($extra); |
||
| 93 | } |
||
| 94 | $ret .= $tray->render(); |
||
| 95 | $ret .= "\n"; |
||
| 96 | } |
||
| 97 | |||
| 98 | $ret .= $hidden . "\n"; |
||
| 99 | $ret .= '</div>' . "\n"; |
||
| 100 | $ret .= '</div>' . "\n"; |
||
| 101 | return $ret; |
||
| 102 | } |
||
| 104 |