| Conditions | 12 |
| Paths | 143 |
| Total Lines | 66 |
| Code Lines | 46 |
| 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 |
||
| 56 | public function Stroke($aImg, &$grid, $aPos, $aAxisAngle, $aScale, &$aMajPos, &$aMajLabel) |
||
| 57 | { |
||
| 58 | // Prepare to draw linear ticks |
||
| 59 | $maj_step_abs = abs($aScale->scale_factor * $this->major_step); |
||
| 60 | $min_step_abs = abs($aScale->scale_factor * $this->minor_step); |
||
| 61 | $nbrmaj = round($aScale->world_abs_size / $maj_step_abs); |
||
| 62 | $nbrmin = round($aScale->world_abs_size / $min_step_abs); |
||
| 63 | $skip = round($nbrmin / $nbrmaj); // Don't draw minor on top of major |
||
| 64 | |||
| 65 | // Draw major ticks |
||
| 66 | $ticklen2 = $this->major_abs_size; |
||
| 67 | $dx = round(sin($aAxisAngle) * $ticklen2); |
||
| 68 | $dy = round(cos($aAxisAngle) * $ticklen2); |
||
| 69 | $label = $aScale->scale[0] + $this->major_step; |
||
| 70 | |||
| 71 | $aImg->SetLineWeight($this->weight); |
||
| 72 | |||
| 73 | $aMajPos = []; |
||
| 74 | $aMajLabel = []; |
||
| 75 | |||
| 76 | for ($i = 1; $i <= $nbrmaj; ++$i) { |
||
| 77 | $xt = round($i * $maj_step_abs * cos($aAxisAngle)) + $aScale->scale_abs[0]; |
||
| 78 | $yt = $aPos - round($i * $maj_step_abs * sin($aAxisAngle)); |
||
| 79 | |||
| 80 | if ($this->label_formfunc != '') { |
||
| 81 | $f = $this->label_formfunc; |
||
| 82 | $l = call_user_func($f, $label); |
||
| 83 | } else { |
||
| 84 | $l = $label; |
||
| 85 | } |
||
| 86 | |||
| 87 | $aMajLabel[] = $l; |
||
| 88 | $label += $this->major_step; |
||
| 89 | $grid[] = $xt; |
||
| 90 | $grid[] = $yt; |
||
| 91 | $aMajPos[($i - 1) * 2] = $xt + 2 * $dx; |
||
| 92 | $aMajPos[($i - 1) * 2 + 1] = $yt - $aImg->GetFontheight() / 2; |
||
| 93 | if (!$this->supress_tickmarks) { |
||
| 94 | if ($this->majcolor != '') { |
||
| 95 | $aImg->PushColor($this->majcolor); |
||
| 96 | } |
||
| 97 | $aImg->Line($xt + $dx, $yt + $dy, $xt - $dx, $yt - $dy); |
||
| 98 | if ($this->majcolor != '') { |
||
| 99 | $aImg->PopColor(); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | // Draw minor ticks |
||
| 105 | $ticklen2 = $this->minor_abs_size; |
||
| 106 | $dx = round(sin($aAxisAngle) * $ticklen2); |
||
| 107 | $dy = round(cos($aAxisAngle) * $ticklen2); |
||
| 108 | if (!$this->supress_tickmarks && !$this->supress_minor_tickmarks) { |
||
| 109 | if ($this->mincolor != '') { |
||
| 110 | $aImg->PushColor($this->mincolor); |
||
| 111 | } |
||
| 112 | for ($i = 1; $i <= $nbrmin; ++$i) { |
||
| 113 | if (($i % $skip) == 0) { |
||
| 114 | continue; |
||
| 115 | } |
||
| 116 | $xt = round($i * $min_step_abs * cos($aAxisAngle)) + $aScale->scale_abs[0]; |
||
| 117 | $yt = $aPos - round($i * $min_step_abs * sin($aAxisAngle)); |
||
| 118 | $aImg->Line($xt + $dx, $yt + $dy, $xt - $dx, $yt - $dy); |
||
| 119 | } |
||
| 120 | if ($this->mincolor != '') { |
||
| 121 | $aImg->PopColor(); |
||
| 122 | } |
||
| 126 |