From 279e23c26397192d6465783b8a356e2e1f7bd2d1 Mon Sep 17 00:00:00 2001 From: Christian Alexander Wolf Date: Fri, 13 Mar 2020 15:35:45 +0100 Subject: [PATCH] fix: implement json serializable --- src/MonitoringData.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/MonitoringData.php b/src/MonitoringData.php index e06022a..554d152 100644 --- a/src/MonitoringData.php +++ b/src/MonitoringData.php @@ -5,9 +5,10 @@ namespace Phash; use DateTimeInterface; +use JsonSerializable; use RuntimeException; -class MonitoringData +class MonitoringData implements JsonSerializable { public const STATUS_OK = 'ok'; public const STATUS_ERROR = 'error'; @@ -41,7 +42,7 @@ public function __construct( $this->payload = $payload; $this->idleTimeoutInSeconds = $idleTimeoutInSeconds; $this->priority = $priority; - $this->date = $date; + $this->date = $date->format('Y-m-d H:i:s'); $this->path = $path; } @@ -80,7 +81,7 @@ public function getPriority(): int return $this->priority; } - public function getDate(): DateTimeInterface + public function getDate(): string { return $this->date; } @@ -99,4 +100,8 @@ public function getTileExpansionGrowthExpression(): ?string { return $this->tileExpansionGrowthExpression; } + + public function jsonSerialize() { + return get_object_vars($this); + } }