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    case USER = 'ROLE_USER';
10    case ADMIN = 'ROLE_ADMIN';
11
12    public function cssClass(): string
13    {
14        return match ($this) {
15            self::USER => 'badge bg-secondary',
16            self::ADMIN => 'badge bg-danger',
17        };
18    }
19
20    public function label(): string
21    {
22        return match ($this) {
23            self::ADMIN => 'Administrator',
24            self::USER => 'User',
25        };
26    }
27}