| Conditions | 11 |
| Paths | 320 |
| Total Lines | 88 |
| Code Lines | 52 |
| 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 |
||
| 62 | public function AddSliceToCSIM($i, $xc, $yc, $radius, $sa, $ea) |
||
| 63 | { |
||
| 64 | //Slice number, ellipse centre (x,y), radius, start angle, end angle |
||
| 65 | while ($sa > 2 * M_PI) { |
||
| 66 | $sa = $sa - 2 * M_PI; |
||
| 67 | } |
||
| 68 | |||
| 69 | while ($ea > 2 * M_PI) { |
||
| 70 | $ea = $ea - 2 * M_PI; |
||
| 71 | } |
||
| 72 | |||
| 73 | $sa = 2 * M_PI - $sa; |
||
| 74 | $ea = 2 * M_PI - $ea; |
||
| 75 | |||
| 76 | // Special case when we have only one slice since then both start and end |
||
| 77 | // angle will be == 0 |
||
| 78 | if (abs($sa - $ea) < 0.0001) { |
||
| 79 | $sa = 2 * M_PI; |
||
| 80 | $ea = 0; |
||
| 81 | } |
||
| 82 | |||
| 83 | // Add inner circle first point |
||
| 84 | $xp = floor(($this->imidsize * $radius * cos($ea)) + $xc); |
||
| 85 | $yp = floor($yc - ($this->imidsize * $radius * sin($ea))); |
||
| 86 | $coords = "${xp}, ${yp}"; |
||
| 87 | |||
| 88 | //add coordinates every 0.25 radians |
||
| 89 | $a = $ea + 0.25; |
||
| 90 | |||
| 91 | // If we cross the 360-limit with a slice we need to handle |
||
| 92 | // the fact that end angle is smaller than start |
||
| 93 | if ($sa < $ea) { |
||
| 94 | while ($a <= 2 * M_PI) { |
||
| 95 | $xp = floor($radius * cos($a) + $xc); |
||
| 96 | $yp = floor($yc - $radius * sin($a)); |
||
| 97 | $coords .= ", ${xp}, ${yp}"; |
||
| 98 | $a += 0.25; |
||
| 99 | } |
||
| 100 | $a -= 2 * M_PI; |
||
| 101 | } |
||
| 102 | |||
| 103 | while ($a < $sa) { |
||
| 104 | $xp = floor(($this->imidsize * $radius * cos($a) + $xc)); |
||
| 105 | $yp = floor($yc - ($this->imidsize * $radius * sin($a))); |
||
| 106 | $coords .= ", ${xp}, ${yp}"; |
||
| 107 | $a += 0.25; |
||
| 108 | } |
||
| 109 | |||
| 110 | // Make sure we end at the last point |
||
| 111 | $xp = floor(($this->imidsize * $radius * cos($sa) + $xc)); |
||
| 112 | $yp = floor($yc - ($this->imidsize * $radius * sin($sa))); |
||
| 113 | $coords .= ", ${xp}, ${yp}"; |
||
| 114 | |||
| 115 | // Straight line to outer circle |
||
| 116 | $xp = floor($radius * cos($sa) + $xc); |
||
| 117 | $yp = floor($yc - $radius * sin($sa)); |
||
| 118 | $coords .= ", ${xp}, ${yp}"; |
||
| 119 | |||
| 120 | //add coordinates every 0.25 radians |
||
| 121 | $a = $sa - 0.25; |
||
| 122 | while ($a > $ea) { |
||
| 123 | $xp = floor($radius * cos($a) + $xc); |
||
| 124 | $yp = floor($yc - $radius * sin($a)); |
||
| 125 | $coords .= ", ${xp}, ${yp}"; |
||
| 126 | $a -= 0.25; |
||
| 127 | } |
||
| 128 | |||
| 129 | //Add the last point on the arc |
||
| 130 | $xp = floor($radius * cos($ea) + $xc); |
||
| 131 | $yp = floor($yc - $radius * sin($ea)); |
||
| 132 | $coords .= ", ${xp}, ${yp}"; |
||
| 133 | |||
| 134 | // Close the arc |
||
| 135 | $xp = floor(($this->imidsize * $radius * cos($ea)) + $xc); |
||
| 136 | $yp = floor($yc - ($this->imidsize * $radius * sin($ea))); |
||
| 137 | $coords .= ", ${xp}, ${yp}"; |
||
| 138 | |||
| 139 | if (!empty($this->csimtargets[$i])) { |
||
| 140 | $this->csimareas .= "<area shape=\"poly\" coords=\"${coords}\" href=\"" . |
||
| 141 | $this->csimtargets[$i] . '"'; |
||
| 142 | if (!empty($this->csimwintargets[$i])) { |
||
| 143 | $this->csimareas .= ' target="' . $this->csimwintargets[$i] . '" '; |
||
| 144 | } |
||
| 145 | if (!empty($this->csimalts[$i])) { |
||
| 146 | $tmp = sprintf($this->csimalts[$i], $this->data[$i]); |
||
| 147 | $this->csimareas .= " title=\"${tmp}\" alt=\"${tmp}\" "; |
||
| 148 | } |
||
| 149 | $this->csimareas .= " />\n"; |
||
| 150 | } |
||
| 222 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.