| Conditions | 10 |
| Paths | 12 |
| Total Lines | 45 |
| Code Lines | 25 |
| 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 |
||
| 35 | public function Stroke($pos, $aAxisAngle, &$grid, $title, $lf) |
||
| 36 | { |
||
| 37 | $this->img->SetColor($this->color); |
||
| 38 | |||
| 39 | // Determine end points for the axis |
||
| 40 | $x = round($this->scale->world_abs_size * cos($aAxisAngle) + $this->scale->scale_abs[0]); |
||
| 41 | $y = round($pos - $this->scale->world_abs_size * sin($aAxisAngle)); |
||
| 42 | |||
| 43 | // Draw axis |
||
| 44 | $this->img->SetColor($this->color); |
||
| 45 | $this->img->SetLineWeight($this->weight); |
||
| 46 | if (!$this->hide) { |
||
| 47 | $this->img->Line($this->scale->scale_abs[0], $pos, $x, $y); |
||
| 48 | } |
||
| 49 | |||
| 50 | $this->scale->ticks->Stroke($this->img, $grid, $pos, $aAxisAngle, $this->scale, $majpos, $majlabel); |
||
| 51 | $ncolor = 0; |
||
| 52 | if (isset($this->ticks_label_colors)) { |
||
| 53 | $ncolor = safe_count($this->ticks_label_colors); |
||
| 54 | } |
||
| 55 | |||
| 56 | // Draw labels |
||
| 57 | if ($lf && !$this->hide) { |
||
| 58 | $this->img->SetFont($this->font_family, $this->font_style, $this->font_size); |
||
| 59 | $this->img->SetTextAlign('left', 'top'); |
||
| 60 | $this->img->SetColor($this->label_color); |
||
| 61 | |||
| 62 | // majpos contains (x,y) coordinates for labels |
||
| 63 | if (!$this->hide_labels) { |
||
| 64 | $n = floor(safe_count($majpos) / 2); |
||
| 65 | for ($i = 0; $i < $n; ++$i) { |
||
| 66 | // Set specific label color if specified |
||
| 67 | if ($ncolor > 0) { |
||
| 68 | $this->img->SetColor($this->ticks_label_colors[$i % $ncolor]); |
||
| 69 | } |
||
| 70 | |||
| 71 | if ($this->ticks_label != null && isset($this->ticks_label[$i])) { |
||
| 72 | $this->img->StrokeText($majpos[$i * 2], $majpos[$i * 2 + 1], $this->ticks_label[$i]); |
||
| 73 | } else { |
||
| 74 | $this->img->StrokeText($majpos[$i * 2], $majpos[$i * 2 + 1], $majlabel[$i]); |
||
| 75 | } |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 | $this->_StrokeAxisTitle($pos, $aAxisAngle, $title); |
||
| 80 | } |
||
| 155 |