Skip to content

Commit

Permalink
Update Ban.php (#8)
Browse files Browse the repository at this point in the history
Return `null` for permanent bans, also set `active` as false for bans with expired date > now
  • Loading branch information
cjmaxik authored and thorerik committed May 2, 2017
1 parent 9748822 commit 7075598
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Types/Ban.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Ban
/**
* Time and Date when the ban expires.
*
* @var Carbon
* @var Carbon|null
*/
public $expires;

Expand Down Expand Up @@ -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'];
Expand Down

0 comments on commit 7075598

Please sign in to comment.