Lines 100.00% 6 / 6
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
UserRole 100.00% 6 / 6 100.00% 2 / 2 6 100.00% 1 / 1
 cssClass 100.00% 3 / 3 100.00% 1 / 1 3
 label 100.00% 3 / 3 100.00% 1 / 1 3
1<?php
2
3declare(strict_types=1);
4
5namespace App\Enum;
6
7enum UserRole: string
8{
9    /** Uploads agent stats and custom medals from the app. */
10    case USER = 'ROLE_USER';
11    case ADMIN = 'ROLE_ADMIN';
12
13    public function cssClass(): string
14    {
15        return match ($this) {
16            self::USER => 'badge bg-secondary',
17            self::ADMIN => 'badge bg-danger',
18        };
19    }
20
21    /** A translation key (messages). */
22    public function label(): string
23    {
24        return match ($this) {
25            self::ADMIN => 'role.admin',
26            self::USER => 'role.user',
27        };
28    }
29}