From 538241f9b7be25a9e3fb5ba27ec35db5c4fc3855 Mon Sep 17 00:00:00 2001 From: Oleksandr Trotsenko Date: Sun, 19 Aug 2018 09:34:16 -0500 Subject: [PATCH 1/2] Introducing a general support for native JSON serialization. --- lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php index adc5a21e..9731e82d 100644 --- a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php +++ b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php @@ -32,7 +32,7 @@ * @author Derek J. Lambert * @license http://dlambert.mit-license.org MIT */ -abstract class AbstractGeometry implements GeometryInterface +abstract class AbstractGeometry implements GeometryInterface, \JsonSerializable { /** * @var int @@ -65,6 +65,13 @@ public function toJson() return json_encode($json); } + /** + * @return array + */ + public function jsonSerialize() { + return $this->toArray(); + } + /** * @return null|int */ From 7013441ca73cd1324bb639ea86b82f50287344a2 Mon Sep 17 00:00:00 2001 From: Oleksandr Trotsenko Date: Sun, 19 Aug 2018 09:38:43 -0500 Subject: [PATCH 2/2] Fixing coding standards! --- lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php index 9731e82d..9f75744d 100644 --- a/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php +++ b/lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php @@ -68,7 +68,8 @@ public function toJson() /** * @return array */ - public function jsonSerialize() { + public function jsonSerialize() + { return $this->toArray(); }