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

UserStatus::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
/**
8
 * User authentication status.
9
 */
10
enum UserStatus: string
11
{
12
    use EnumToArray;
13
14
    // First letter uppercase and rest lowercase because these names are used as labels in html form as they are
15
    case Unverified = 'unverified'; // Default after registration
16
    case Active = 'active'; // Verified via token received in email
17
    case Locked = 'locked'; // Locked for security reasons, may be reactivated by account holder via email
18
    case Suspended = 'suspended'; // User suspended, account holder not allowed to login even via email
19
20
    // UserStatus::toArray() returns array for dropdown
21
22
    /**
23
     * Get the enum case name that can be displayed by the frontend.
24
     *
25
     * @return string
26
     */
27 7
    public function getDisplayName(): string
28
    {
29 7
        return match ($this) {
30 7
            self::Unverified => __('Unverified'),
31 7
            self::Active => __('Active'),
32 7
            self::Locked => __('Locked'),
33 7
            self::Suspended => __('Suspended'),
34 7
        };
35
    }
36
}
37