From 10e1368942e1fb3b86bceef6064e7b3d5f3fd43a Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 29 Jan 2025 15:40:40 -0500 Subject: [PATCH] Added the ability to parse created and expired as strings/null --- .../Objects/Database/SigningKeyRecord.php | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Socialbox/Objects/Database/SigningKeyRecord.php b/src/Socialbox/Objects/Database/SigningKeyRecord.php index c00bc3e..62ac8af 100644 --- a/src/Socialbox/Objects/Database/SigningKeyRecord.php +++ b/src/Socialbox/Objects/Database/SigningKeyRecord.php @@ -47,9 +47,24 @@ { $this->expires = $data['expires']->getTimestamp(); } + elseif(is_string($data['expires'])) + { + if(empty($data['expires'])) + { + $this->expires = 0; + } + else + { + $this->expires = strtotime($data['expires']); + } + } + elseif($data['expires'] === null) + { + $this->expires = 0; + } else { - throw new InvalidArgumentException('Invalid expires value'); + throw new InvalidArgumentException('Invalid expires value, got type: ' . gettype($data['expires'])); } if(is_int($data['created'])) @@ -60,9 +75,20 @@ { $this->created = $data['created']->getTimestamp(); } + elseif(is_string($data['created'])) + { + if(empty($data['created'])) + { + $this->created = 0; + } + else + { + $this->created = strtotime($data['created']); + } + } else { - throw new InvalidArgumentException('Invalid created value'); + throw new InvalidArgumentException('Invalid created value type, got ' . gettype($data['created'])); } }