mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 04:01:24 +00:00
44 lines
819 B
PHP
44 lines
819 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Enums;
|
|
|
|
enum UserRole: int
|
|
{
|
|
case USER = 1;
|
|
case ADMIN = 2;
|
|
case DISABLED = 3;
|
|
case MODERATOR = 4;
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::USER => 'User',
|
|
self::ADMIN => 'Admin',
|
|
self::DISABLED => 'Disabled',
|
|
self::MODERATOR => 'Moderator',
|
|
};
|
|
}
|
|
|
|
public function isAdmin(): bool
|
|
{
|
|
return $this === self::ADMIN;
|
|
}
|
|
|
|
public function isModerator(): bool
|
|
{
|
|
return $this === self::MODERATOR;
|
|
}
|
|
|
|
public function isDisabled(): bool
|
|
{
|
|
return $this === self::DISABLED;
|
|
}
|
|
|
|
public function hasElevatedPrivileges(): bool
|
|
{
|
|
return in_array($this, [self::ADMIN, self::MODERATOR], true);
|
|
}
|
|
}
|