| Conditions | 10 |
| Paths | 32 |
| Total Lines | 51 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 84 | public function getHTML() : string |
||
| 85 | { |
||
| 86 | $this->processFlags(); |
||
| 87 | |||
| 88 | $strSelect = $this->oFG->getData()->getValue($this->strName); |
||
| 89 | $aOptions = $this->aOptions ?: $this->oFG->getData()->getSelectOptions($this->strName); |
||
| 90 | |||
| 91 | $strWidth = ($this->oParent ? $this->oParent->getColWidth($this->iCol) : ''); |
||
| 92 | $strHTML = ''; |
||
| 93 | $strHTML .= ' '; |
||
| 94 | $strHTML .= '<div style="float: left; position: relative;'; |
||
| 95 | if (!empty($strWidth)) { |
||
| 96 | $strHTML .= ' width: ' . $strWidth . ';'; |
||
| 97 | } |
||
| 98 | $strHTML .= '">'; |
||
| 99 | if ($this->oFlags->isSet(FormFlags::SELECT_BTN)) { |
||
| 100 | $strHTML .= '<button class="sbBtn">' . $this->strSelectBtnText . '</button>'; |
||
| 101 | } |
||
| 102 | $strHTML .= '<select'; |
||
| 103 | $strHTML .= ' class="' . $this->strClass . '"'; |
||
| 104 | $strHTML .= ' name="' . $this->strName . '"'; |
||
| 105 | $strHTML .= ' id="' . $this->strName . '"'; |
||
| 106 | if ($this->size > 0) { |
||
| 107 | $strHTML .= ' size="' . $this->size . '"'; |
||
| 108 | } |
||
| 109 | $strHTML .= $this->buildStyle(); |
||
| 110 | $strHTML .= $this->buildAttributes(); |
||
| 111 | $strHTML .= $this->buildTabindex(); |
||
| 112 | $strHTML .= '>' . PHP_EOL; |
||
| 113 | |||
| 114 | if (count($aOptions) > 0) { |
||
| 115 | foreach ($aOptions as $strOption => $strValue) { |
||
| 116 | $strHTML .= ' '; |
||
| 117 | $strHTML .= '<option '; |
||
| 118 | if ($strValue == $strSelect) { |
||
| 119 | $strHTML .= 'selected '; |
||
| 120 | } |
||
| 121 | if (strlen($strOption) == 0) { |
||
| 122 | // to prevent HTML5 validation error "Element option without attribute label must not be empty." |
||
| 123 | $strOption = ' '; |
||
| 124 | } |
||
| 125 | $strHTML .= 'value="' . $strValue . '">' . $strOption . '</option>' . PHP_EOL; |
||
| 126 | } |
||
| 127 | } else { |
||
| 128 | // dropdown selectlist without options... |
||
| 129 | trigger_error('empty select options set!', E_USER_NOTICE); |
||
| 130 | } |
||
| 131 | |||
| 132 | $strHTML .= ' </select></div>' . PHP_EOL; |
||
| 133 | |||
| 134 | return $strHTML; |
||
| 135 | } |
||
| 162 |