Passed
Push — master ( 8ff4e3...ffee1f )
by Samuel
03:00
created

UserRole::getDisplayName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Domain\User\Enum;
4
5
use App\Common\Trait\EnumToArray;
6
7
enum UserRole: string
8
{
9
    use EnumToArray;
10
11
    // Value is `user_role`.`name`
12
    case NEWCOMER = 'newcomer';
13
    case ADVISOR = 'advisor';
14
    case MANAGING_ADVISOR = 'managing_advisor';
15
    case ADMIN = 'admin';
16
17
    /**
18
     * Get the enum case name that can be displayed by the frontend.
19
     *
20
     * @return string
21
     */
22 10
    public function getDisplayName(): string
23
    {
24 10
        return match ($this) {
25 10
            self::NEWCOMER => __('Newcomer'),
26 10
            self::ADVISOR => __('Advisor'),
27 10
            self::MANAGING_ADVISOR => __('Managing advisor'),
28 10
            self::ADMIN => __('Admin'),
29 10
        };
30
    }
31
}
32