| Conditions | 10 |
| Paths | 17 |
| Total Lines | 21 |
| Code Lines | 12 |
| 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 |
||
| 132 | public function smallestRectangularEnvelope() |
||
| 133 | { |
||
| 134 | $minX = $minY = $maxX = $maxY = null; |
||
| 135 | /** @var Point $point */ |
||
| 136 | foreach ($this as $point) { |
||
| 137 | if ($minX === null || $minX > $point->getX()) { |
||
| 138 | $minX = $point->getX(); |
||
| 139 | } |
||
| 140 | if ($minY === null || $minY > $point->getY()) { |
||
| 141 | $minY = $point->getY(); |
||
| 142 | } |
||
| 143 | if ($maxX === null || $maxX < $point->getX()) { |
||
| 144 | $maxX = $point->getX(); |
||
| 145 | } |
||
| 146 | if ($maxY === null || $maxY < $point->getY()) { |
||
| 147 | $maxY = $point->getY(); |
||
| 148 | } |
||
| 149 | } |
||
| 150 | |||
| 151 | return new Line(new Point($minX, $minY), new Point($maxX, $maxY)); |
||
| 152 | } |
||
| 153 | } |
||
| 154 |