Passed
Push — develop ( 142042...e2d041 )
by Septianata
04:21
created

Gender   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 25
ccs 4
cts 8
cp 0.5
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 6 1
A labels() 0 6 1
1
<?php
2
3
namespace App\Enum;
4
5
use Spatie\Enum\Laravel\Enum;
6
7
/**
8
 * @method static self male()
9
 * @method static self female()
10
 * @method static self undefined()
11
 */
12
class Gender extends Enum
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17 1
    protected static function labels(): array
18
    {
19
        return [
20 1
            'male' => trans('Male'),
21 1
            'female' => trans('Female'),
22 1
            'undefined' => trans('Undefined'),
23
        ];
24
    }
25
26
    /**
27
     * Return specified title based on the current enum.
28
     *
29
     * @return string|null
30
     */
31
    protected function getTitle(): ?string
32
    {
33
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array('male' => t...)[$this->value] ?? null could return the type array which is incompatible with the type-hinted return null|string. Consider adding an additional type-check to rule them out.
Loading history...
34
            'male' => trans('Mr.'),
35
            'female' => trans('Mrs.'),
36
        ][$this->value] ?? null;
37
    }
38
}
39