From 7b764ac880e54870e84e0a7d7f2e1bd3ac9e5181 Mon Sep 17 00:00:00 2001 From: Flerex Date: Mon, 25 Jan 2021 13:56:23 +0100 Subject: [PATCH] Location objects can be stringified --- src/Dtos/DegreesLocation.php | 9 +++++++-- src/Dtos/Location.php | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Dtos/DegreesLocation.php b/src/Dtos/DegreesLocation.php index 0466eed..9378477 100644 --- a/src/Dtos/DegreesLocation.php +++ b/src/Dtos/DegreesLocation.php @@ -9,7 +9,12 @@ final class DegreesLocation public function __construct(float $latitude, float $longitude) { - $this->latitude = new DegreesCoordinate($latitude, 'N', 'S'); - $this->longitude = new DegreesCoordinate($longitude, 'E', 'W'); + $this->latitude = new DegreesCoordinate($latitude, 'N', 'S'); + $this->longitude = new DegreesCoordinate($longitude, 'E', 'W'); + } + + public function __toString(): string + { + return $this->latitude . ' ' . $this->longitude; } } diff --git a/src/Dtos/Location.php b/src/Dtos/Location.php index 6287f5d..627c500 100644 --- a/src/Dtos/Location.php +++ b/src/Dtos/Location.php @@ -31,4 +31,9 @@ public function toDegrees(): DegreesLocation { return new DegreesLocation($this->latitude, $this->longitude); } + + public function __toString(): string + { + return $this->latitude . ", " . $this->longitude; + } }