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

UserStatus   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 11
c 2
b 0
f 0
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDisplayName() 0 7 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