From 26ec36d5f34e7fc52169509a5b366a88f10a593b Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Fri, 22 Mar 2019 08:22:41 +0100 Subject: [PATCH] add exception message --- src/Formatter/Polygon/GeoJSON.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Formatter/Polygon/GeoJSON.php b/src/Formatter/Polygon/GeoJSON.php index 59a184a..3d06c57 100644 --- a/src/Formatter/Polygon/GeoJSON.php +++ b/src/Formatter/Polygon/GeoJSON.php @@ -24,8 +24,9 @@ class GeoJSON implements FormatterInterface public function format(Polygon $polygon): string { if ($polygon->getNumberOfPoints() < 3) { - throw new InvalidPolygonException(); + throw new InvalidPolygonException('A polygon must consist of at least three points.'); } + $points = []; /** @var Coordinate $point */ @@ -35,7 +36,7 @@ public function format(Polygon $polygon): string return json_encode( [ - 'type' => 'Polygon', + 'type' => 'Polygon', 'coordinates' => [$points], ] );