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

Gender::labels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
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