From 92a5f54573f7594f927aaba2715fa0ecdf8d9f3e Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Fri, 26 May 2023 19:51:09 +0300 Subject: [PATCH] Added an ability to get timestamp as it is (#863) * Added an ability to get timestamp as it is * Fix style --- src/Model/Event/Event.php | 20 ++++++++++++++++++++ tests/Model/Event/EventResponseTest.php | 1 + 2 files changed, 21 insertions(+) diff --git a/src/Model/Event/Event.php b/src/Model/Event/Event.php index 6d741263..50c4a3ca 100644 --- a/src/Model/Event/Event.php +++ b/src/Model/Event/Event.php @@ -38,6 +38,7 @@ final class Event private $storage; private $method; private $logLevel; + private $rawTimestamp; private function __construct() { @@ -68,6 +69,7 @@ public static function create(array $data): self $model->url = $data['url'] ?? ''; $model->storage = $data['storage'] ?? []; $model->logLevel = $data['log-level'] ?? ''; + $model->rawTimestamp = $data['timestamp']; return $model; } @@ -199,4 +201,22 @@ public function getLogLevel(): string { return $this->logLevel; } + + /** + * Return timestamp as it is. + * + * @return mixed + */ + public function getRawTimestamp() + { + return $this->rawTimestamp; + } + + /** + * @param mixed $rawTimestamp + */ + public function setRawTimestamp($rawTimestamp): void + { + $this->rawTimestamp = $rawTimestamp; + } } diff --git a/tests/Model/Event/EventResponseTest.php b/tests/Model/Event/EventResponseTest.php index 9f71cbd0..0833ea9d 100644 --- a/tests/Model/Event/EventResponseTest.php +++ b/tests/Model/Event/EventResponseTest.php @@ -71,5 +71,6 @@ public function testCreate() $event = $events[0]; $this->assertEquals('czsjqFATSlC3QtAK-C80nw', $event->getId()); $this->assertEquals('info', $event->getLogLevel()); + $this->assertNotEquals($event->getRawTimestamp(), $event->getTimestamp()); } }