| Conditions | 12 |
| Paths | 210 |
| Total Lines | 75 |
| Code Lines | 48 |
| 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 |
||
| 156 | public function Stroke($aImg, $aXLeft, $aYTop, $aXRight, $aYBottom, $aUseTextHeight = false) |
||
| 157 | { |
||
| 158 | if (!$this->iShow) { |
||
| 159 | return; |
||
| 160 | } |
||
| 161 | |||
| 162 | $txt = new Text\TextProperty(); |
||
| 163 | $txt->SetFont($this->iFFamily, $this->iFStyle, $this->iFSize); |
||
| 164 | $txt->SetColor($this->iFontColor); |
||
| 165 | $txt->SetAlign($this->iHeaderAlign, 'top'); |
||
| 166 | $n = safe_count($this->iTitles); |
||
| 167 | |||
| 168 | if ($n == 0) { |
||
| 169 | return; |
||
| 170 | } |
||
| 171 | |||
| 172 | $x = $aXLeft; |
||
| 173 | $h = $this->iHeight; |
||
| 174 | $yTop = $aUseTextHeight ? $aYBottom - $h - $this->iTopColMargin - $this->iBottomColMargin : $aYTop; |
||
| 175 | |||
| 176 | if ($h < 0) { |
||
| 177 | Util\JpGraphError::RaiseL(6001); |
||
| 178 | //('Internal error. Height for ActivityTitles is < 0'); |
||
| 179 | } |
||
| 180 | |||
| 181 | $aImg->SetLineWeight(1); |
||
| 182 | // Set background color |
||
| 183 | $aImg->SetColor($this->iBackgroundColor); |
||
| 184 | $aImg->FilledRectangle($aXLeft, $yTop, $aXRight, $aYBottom - 1); |
||
| 185 | |||
| 186 | if ($this->iStyle == 1) { |
||
| 187 | // Make a 3D effect |
||
| 188 | $aImg->SetColor('white'); |
||
| 189 | $aImg->Line($aXLeft, $yTop + 1, $aXRight, $yTop + 1); |
||
| 190 | } |
||
| 191 | |||
| 192 | for ($i = 0; $i < $n; ++$i) { |
||
| 193 | if ($this->iStyle == 1) { |
||
| 194 | // Make a 3D effect |
||
| 195 | $aImg->SetColor('white'); |
||
| 196 | $aImg->Line($x + 1, $yTop, $x + 1, $aYBottom); |
||
| 197 | } |
||
| 198 | $x += $this->iLeftColMargin; |
||
| 199 | $txt->Set($this->iTitles[$i]); |
||
| 200 | |||
| 201 | // Adjust the text anchor position according to the choosen alignment |
||
| 202 | $xp = $x; |
||
| 203 | if ($this->iHeaderAlign == 'center') { |
||
| 204 | $xp = (($x - $this->iLeftColMargin) + ($x + $this->iWidth[$i])) / 2; |
||
| 205 | } elseif ($this->iHeaderAlign == 'right') { |
||
| 206 | $xp = $x + $this->iWidth[$i] - $this->iRightColMargin; |
||
| 207 | } |
||
| 208 | |||
| 209 | $txt->Stroke($aImg, $xp, $yTop + $this->iTopHeaderMargin); |
||
| 210 | $x += $this->iWidth[$i]; |
||
| 211 | if ($i < $n - 1) { |
||
| 212 | $aImg->SetColor($this->iColor); |
||
| 213 | $aImg->Line($x, $yTop, $x, $aYBottom); |
||
| 214 | } |
||
| 215 | } |
||
| 216 | |||
| 217 | $aImg->SetColor($this->iColor); |
||
| 218 | $aImg->Line($aXLeft, $yTop, $aXRight, $yTop); |
||
| 219 | |||
| 220 | // Stroke vertical column dividers |
||
| 221 | $cols = []; |
||
| 222 | $this->GetColStart($aImg, $cols); |
||
| 223 | $n = safe_count($cols); |
||
| 224 | for ($i = 1; $i < $n; ++$i) { |
||
| 225 | $this->vgrid->Stroke( |
||
| 226 | $aImg, |
||
| 227 | $cols[$i], |
||
| 228 | $aYBottom, |
||
| 229 | $cols[$i], |
||
| 230 | $aImg->height - $aImg->bottom_margin |
||
| 231 | ); |
||
| 235 |