From a5e4bd4ab21a65b495d523162e48b54bfd8fbe9c Mon Sep 17 00:00:00 2001 From: Max Mekenya Date: Thu, 27 Apr 2017 19:45:26 +1000 Subject: [PATCH] Update Ban.php Return `null` for permanent bans, also set `active` as false for bans with expired date > now --- src/Types/Ban.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Types/Ban.php b/src/Types/Ban.php index 30c23ad..369cad3 100644 --- a/src/Types/Ban.php +++ b/src/Types/Ban.php @@ -9,7 +9,7 @@ class Ban /** * Time and Date when the ban expires. * - * @var Carbon + * @var Carbon|null */ public $expires; @@ -55,9 +55,23 @@ class Ban */ public function __construct($ban) { - $this->expires = new Carbon($ban['expiration'], 'UTC'); + // Expiration + if ($ban['expiration'] === null) { + $this->expires = null; + } else { + $this->expires = new Carbon($ban['expiration'], 'UTC'); + } + + // Time Added $this->created = new Carbon($ban['timeAdded'], 'UTC'); - $this->active = $ban['active']; + + // Active + $this->active = $ban['active']; + if (!is_null($this->expires) && $this->active) { + if (!$this->expires->greaterThan(Carbon::now('UTC'))) { + $this->active = false; + } + } $this->reason = $ban['reason']; $this->adminName = $ban['adminName'];