| Conditions | 22 |
| Paths | 8192 |
| Total Lines | 70 |
| Code Lines | 32 |
| 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 |
||
| 82 | public function _StrokeAxisTitle($pos, $aAxisAngle, $title) |
||
| 83 | { |
||
| 84 | $this->title->Set($title); |
||
| 85 | $marg = 6 + $this->title->margin; |
||
| 86 | $xt = round(($this->scale->world_abs_size + $marg) * cos($aAxisAngle) + $this->scale->scale_abs[0]); |
||
| 87 | $yt = round($pos - ($this->scale->world_abs_size + $marg) * sin($aAxisAngle)); |
||
| 88 | |||
| 89 | // Position the axis title. |
||
| 90 | // dx, dy is the offset from the top left corner of the bounding box that sorrounds the text |
||
| 91 | // that intersects with the extension of the corresponding axis. The code looks a little |
||
| 92 | // bit messy but this is really the only way of having a reasonable position of the |
||
| 93 | // axis titles. |
||
| 94 | if ($this->title->iWordwrap > 0) { |
||
| 95 | $title = wordwrap($title, $this->title->iWordwrap, "\n"); |
||
| 96 | } |
||
| 97 | |||
| 98 | $h = $this->img->GetTextHeight($title) * 1.2; |
||
| 99 | $w = $this->img->GetTextWidth($title) * 1.2; |
||
| 100 | |||
| 101 | while ($aAxisAngle > 2 * M_PI) { |
||
| 102 | $aAxisAngle -= 2 * M_PI; |
||
| 103 | } |
||
| 104 | |||
| 105 | // Around 3 a'clock |
||
| 106 | if ($aAxisAngle >= 7 * M_PI / 4 || $aAxisAngle <= M_PI / 4) { |
||
| 107 | $dx = -0.15; |
||
| 108 | } |
||
| 109 | // Small trimming to make the dist to the axis more even |
||
| 110 | |||
| 111 | // Around 12 a'clock |
||
| 112 | if ($aAxisAngle >= M_PI / 4 && $aAxisAngle <= 3 * M_PI / 4) { |
||
| 113 | $dx = ($aAxisAngle - M_PI / 4) * 2 / M_PI; |
||
| 114 | } |
||
| 115 | |||
| 116 | // Around 9 a'clock |
||
| 117 | if ($aAxisAngle >= 3 * M_PI / 4 && $aAxisAngle <= 5 * M_PI / 4) { |
||
| 118 | $dx = 1; |
||
| 119 | } |
||
| 120 | |||
| 121 | // Around 6 a'clock |
||
| 122 | if ($aAxisAngle >= 5 * M_PI / 4 && $aAxisAngle <= 7 * M_PI / 4) { |
||
| 123 | $dx = (1 - ($aAxisAngle - M_PI * 5 / 4) * 2 / M_PI); |
||
| 124 | } |
||
| 125 | |||
| 126 | if ($aAxisAngle >= 7 * M_PI / 4) { |
||
| 127 | $dy = (($aAxisAngle - M_PI) - 3 * M_PI / 4) * 2 / M_PI; |
||
| 128 | } |
||
| 129 | |||
| 130 | if ($aAxisAngle <= M_PI / 12) { |
||
| 131 | $dy = (0.5 - $aAxisAngle * 2 / M_PI); |
||
| 132 | } |
||
| 133 | |||
| 134 | if ($aAxisAngle <= M_PI / 4 && $aAxisAngle > M_PI / 12) { |
||
| 135 | $dy = (1 - $aAxisAngle * 2 / M_PI); |
||
| 136 | } |
||
| 137 | |||
| 138 | if ($aAxisAngle >= M_PI / 4 && $aAxisAngle <= 3 * M_PI / 4) { |
||
| 139 | $dy = 1; |
||
| 140 | } |
||
| 141 | |||
| 142 | if ($aAxisAngle >= 3 * M_PI / 4 && $aAxisAngle <= 5 * M_PI / 4) { |
||
| 143 | $dy = (1 - ($aAxisAngle - 3 * M_PI / 4) * 2 / M_PI); |
||
| 144 | } |
||
| 145 | |||
| 146 | if ($aAxisAngle >= 5 * M_PI / 4 && $aAxisAngle <= 7 * M_PI / 4) { |
||
| 147 | $dy = 0; |
||
| 148 | } |
||
| 149 | |||
| 150 | if (!$this->hide) { |
||
| 151 | $this->title->Stroke($this->img, $xt - $dx * $w, $yt - $dy * $h, $title); |
||
| 152 | } |
||
| 155 |