SexOption   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDisplayName() 0 6 1
1
<?php
2
3
namespace App\Module\FormOption;
4
5
use App\Common\Trait\EnumToArray;
6
7
enum SexOption: string
8
{
9
    use EnumToArray;
10
11
    case MALE = 'M';
12
    case FEMALE = 'F';
13
    case OTHER = 'O';
14
    // Cannot have null as it is displayed in the create form as radio buttons
15
    // case NULL = '';
16
17
    /**
18
     * Returns the enum case name that can be displayed by the frontend.
19
     *
20
     * @return string
21
     */
22 6
    public function getDisplayName(): string
23
    {
24 6
        return match ($this) {
25 6
            self::MALE => __('Male'),
26 6
            self::FEMALE => __('Female'),
27 6
            self::OTHER => __('Other'),
28 6
        };
29
    }
30
}
31