| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public function findCentroid(PointCollectionInterface $points): PointInterface |
||
| 24 | { |
||
| 25 | if (! $points->getSpace() instanceof Space) { |
||
| 26 | throw new \InvalidArgumentException( |
||
| 27 | "Point collection should consist of GPS coordinates" |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** @var array<Point> $pointsArray */ |
||
| 32 | $pointsArray = iterator_to_array($points); |
||
| 33 | |||
| 34 | return $points->getSpace()->makePoint(Math::gpsCentroid( |
||
| 35 | array_map(fn (Point $point) => $point->getCoordinates(), $pointsArray) |
||
| 36 | )); |
||
| 39 |