From 8eb3dcf2e203f54f1311ce4d04b294979dd353ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Mon, 25 May 2020 18:54:37 +0200 Subject: [PATCH] MAPG-47 add toArray() method to Bounds --- src/Util/Geo/Bounds.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Util/Geo/Bounds.php b/src/Util/Geo/Bounds.php index c77d2b1..7b448be 100644 --- a/src/Util/Geo/Bounds.php +++ b/src/Util/Geo/Bounds.php @@ -75,18 +75,23 @@ class Bounds return $m * ($a + $c) / 2; } - public function toJson(): string + public function toArray(): array { if (!$this->initialized) { throw new \Exception("Bounds are not initialized!"); } - return json_encode([ + return [ 'south' => $this->southLat, 'west' => $this->westLng, 'north' => $this->northLat, 'east' => $this->eastLng, - ]); + ]; + } + + public function toJson(): string + { + return json_encode($this->toArray()); } private function initialize(Position $position)