| Conditions | 24 |
| Paths | 589 |
| Total Lines | 100 |
| Code Lines | 68 |
| 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 |
||
| 27 | public function Stroke($aOtherAxisScale, $aStrokeLabels = true) |
||
| 28 | { |
||
| 29 | if ($this->hide) { |
||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (is_numeric($this->pos)) { |
||
|
|
|||
| 34 | $pos = $aOtherAxisScale->Translate($this->pos); |
||
| 35 | } else { |
||
| 36 | // Default to minimum of other scale if pos not set |
||
| 37 | if (($aOtherAxisScale->GetMinVal() >= 0 && $this->pos == false) || $this->pos == 'min') { |
||
| 38 | $pos = $aOtherAxisScale->scale_abs[0]; |
||
| 39 | } elseif ($this->pos == 'max') { |
||
| 40 | $pos = $aOtherAxisScale->scale_abs[1]; |
||
| 41 | } else { |
||
| 42 | // If negative set x-axis at 0 |
||
| 43 | $this->pos = 0; |
||
| 44 | $pos = $aOtherAxisScale->Translate(0); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | $pos += $this->iDeltaAbsPos; |
||
| 49 | $this->img->SetLineWeight($this->weight); |
||
| 50 | $this->img->SetColor($this->color); |
||
| 51 | $this->img->SetFont($this->font_family, $this->font_style, $this->font_size); |
||
| 52 | |||
| 53 | if ($this->scale->type == 'x') { |
||
| 54 | if (!$this->hide_line) { |
||
| 55 | // Stroke X-axis |
||
| 56 | $this->img->FilledRectangle( |
||
| 57 | $this->img->left_margin, |
||
| 58 | $pos, |
||
| 59 | $this->img->width - $this->img->right_margin, |
||
| 60 | $pos + $this->weight - 1 |
||
| 61 | ); |
||
| 62 | } |
||
| 63 | if ($this->title_side == SIDE_DOWN) { |
||
| 64 | $y = $pos + $this->img->GetFontHeight() + $this->title_margin + $this->title->margin; |
||
| 65 | $yalign = 'top'; |
||
| 66 | } else { |
||
| 67 | $y = $pos - $this->img->GetFontHeight() - $this->title_margin - $this->title->margin; |
||
| 68 | $yalign = 'bottom'; |
||
| 69 | } |
||
| 70 | |||
| 71 | if ($this->title_adjust == 'high') { |
||
| 72 | $this->title->SetPos($this->img->width - $this->img->right_margin, $y, 'right', $yalign); |
||
| 73 | } elseif ($this->title_adjust == 'middle' || $this->title_adjust == 'center') { |
||
| 74 | $this->title->SetPos(($this->img->width - $this->img->left_margin - $this->img->right_margin) / 2 + $this->img->left_margin, $y, 'center', $yalign); |
||
| 75 | } elseif ($this->title_adjust == 'low') { |
||
| 76 | $this->title->SetPos($this->img->left_margin, $y, 'left', $yalign); |
||
| 77 | } else { |
||
| 78 | Util\JpGraphError::RaiseL(25060, $this->title_adjust); //('Unknown alignment specified for X-axis title. ('.$this->title_adjust.')'); |
||
| 79 | } |
||
| 80 | } elseif ($this->scale->type == 'y') { |
||
| 81 | // Add line weight to the height of the axis since |
||
| 82 | // the x-axis could have a width>1 and we want the axis to fit nicely together. |
||
| 83 | if (!$this->hide_line) { |
||
| 84 | // Stroke Y-axis |
||
| 85 | $this->img->FilledRectangle( |
||
| 86 | $pos - $this->weight + 1, |
||
| 87 | $this->img->top_margin, |
||
| 88 | $pos, |
||
| 89 | $this->img->height - $this->img->bottom_margin + $this->weight - 1 |
||
| 90 | ); |
||
| 91 | } |
||
| 92 | |||
| 93 | $x = $pos; |
||
| 94 | if ($this->title_side == SIDE_LEFT) { |
||
| 95 | $x -= $this->title_margin; |
||
| 96 | $x -= $this->title->margin; |
||
| 97 | $halign = 'right'; |
||
| 98 | } else { |
||
| 99 | $x += $this->title_margin; |
||
| 100 | $x += $this->title->margin; |
||
| 101 | $halign = 'left'; |
||
| 102 | } |
||
| 103 | // If the user has manually specified an hor. align |
||
| 104 | // then we override the automatic settings with this |
||
| 105 | // specifed setting. Since default is 'left' we compare |
||
| 106 | // with that. (This means a manually set 'left' align |
||
| 107 | // will have no effect.) |
||
| 108 | if ($this->title->halign != 'left') { |
||
| 109 | $halign = $this->title->halign; |
||
| 110 | } |
||
| 111 | if ($this->title_adjust == 'high') { |
||
| 112 | $this->title->SetPos($x, $this->img->top_margin, $halign, 'top'); |
||
| 113 | } elseif ($this->title_adjust == 'middle' || $this->title_adjust == 'center') { |
||
| 114 | $this->title->SetPos($x, ($this->img->height - $this->img->top_margin - $this->img->bottom_margin) / 2 + $this->img->top_margin, $halign, 'center'); |
||
| 115 | } elseif ($this->title_adjust == 'low') { |
||
| 116 | $this->title->SetPos($x, $this->img->height - $this->img->bottom_margin, $halign, 'bottom'); |
||
| 117 | } else { |
||
| 118 | Util\JpGraphError::RaiseL(25061, $this->title_adjust); //('Unknown alignment specified for Y-axis title. ('.$this->title_adjust.')'); |
||
| 119 | } |
||
| 120 | } |
||
| 121 | $this->scale->ticks->Stroke($this->img, $this->scale, $pos); |
||
| 122 | if ($aStrokeLabels) { |
||
| 123 | if (!$this->hide_labels) { |
||
| 124 | $this->StrokeLabels($pos); |
||
| 125 | } |
||
| 126 | $this->title->Stroke($this->img); |
||
| 127 | } |
||
| 278 |