Conditions | 10 |
Paths | 6 |
Total Lines | 41 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
106 | public function getHTML() : string |
||
107 | { |
||
108 | $this->processFlags(); |
||
109 | |||
110 | $strStyle = ''; |
||
111 | if ($this->oFlags->isSet(FormFlags::ALIGN_CENTER)) { |
||
112 | $strStyle = 'text-align: center;'; |
||
113 | } else if ($this->oFlags->isSet(FormFlags::ALIGN_RIGHT)) { |
||
114 | $strStyle = 'text-align: right;'; |
||
115 | } |
||
116 | |||
117 | $strHTML = $this->buildContainerDiv($strStyle) . PHP_EOL; |
||
118 | $strHTML .= ' <div class="starrate">' . PHP_EOL; |
||
119 | |||
120 | $iSelect = intval($this->oFG->getData()->getValue($this->strName)); |
||
121 | |||
122 | if (is_array($this->aTitles)) { |
||
123 | $iStarCount = count($this->aTitles); |
||
124 | for ($iStar = $iStarCount; $iStar > 0; $iStar--) { |
||
125 | $strInputClassCSS = ($iStar == $iStarCount) ? ' class="best"' : ''; |
||
126 | $strId = $this->strName . 'Star' . $iStar; |
||
127 | $strTitle = ($this->aTitles !== null && isset($this->aTitles[$iStar - 1])) ? $this->aTitles[$iStar - 1] : $iStar . ' Star'; |
||
128 | $strValue = ($this->bSubmitTitle) ? $strTitle : $iStar; |
||
129 | |||
130 | $strHTML .= ' <input' . $strInputClassCSS; |
||
131 | $strHTML .= ' type="radio" id="' . $strId . '"'; |
||
132 | $strHTML .= ($iSelect == $iStar) ? ' checked' : ''; |
||
133 | $strHTML .= ' name="' . $this->strName . '"'; |
||
134 | $strHTML .= $this->buildAttributes(); |
||
135 | $strHTML .= ' value="' . $strValue . '"/>' . PHP_EOL; |
||
136 | |||
137 | $strHTML .= ' <label for="' . $strId . '"'; |
||
138 | $strHTML .= ' id="' . $strId . 'Label"'; |
||
139 | $strHTML .= ' title="' . $strTitle . '"></label>' . PHP_EOL; |
||
140 | } |
||
141 | $strHTML .= ' </div>' . PHP_EOL; |
||
142 | |||
143 | $strHTML .= '</div>' . PHP_EOL; |
||
144 | } |
||
145 | |||
146 | return $strHTML; |
||
147 | } |
||
168 |