Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Models/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ class Player
*/
protected $bannedUntil;

/**
* The number of active bans a user has, or null if staff.
*
* @var int|null
*/
protected $activeBanCount;

/**
* If the user has their bans hidden.
*
Expand Down Expand Up @@ -186,6 +193,7 @@ public function __construct(array $player)
$this->groupColor = $player['groupColor'];
$this->isBanned = $player['banned'];
$this->bannedUntil = new Carbon($player['bannedUntil'], 'UTC');
$this->activeBanCount = $player['bansCount'];
$this->displayBans = $player['displayBans'];

$this->patreon = new Patreon(
Expand Down Expand Up @@ -320,6 +328,16 @@ public function getBannedUntilDate(): ?Carbon
return $this->bannedUntil;
}

/**
* Get the player's number of active bans, or null if staff.
*
* @return int|null
*/
public function getActiveBanCount(): ?int
{
return $this->activeBanCount;
}

/**
* Check if the player has their bans hidden.
*
Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/PlayerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ public function it_has_a_banned_until_date()
$this->assertInstanceOf(Carbon::class, $player->getBannedUntilDate());
}

/** @test */
public function it_has_an_active_ban_count()
{
$player = $this->player(self::TEST_ACCOUNT);

if ($player->isStaff()) {
$this->assertNull($player->getActiveBanCount());
} else {
$this->assertIsInt($player->getActiveBanCount());
}
}

/** @test */
public function if_it_has_bans_hidden()
{
Expand Down