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

SexOption::getDisplayName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Domain\General\Enum;
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
     * Get the enum case name that can be displayed by the frontend.
19
     *
20
     * @return string
21
     */
22 5
    public function getDisplayName(): string
23
    {
24 5
        return match ($this) {
25 5
            self::MALE => __('Male'),
26 5
            self::FEMALE => __('Female'),
27 5
            self::OTHER => __('Other'),
28 5
        };
29
    }
30
}
31