EnumWithId::identifierAttribute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace JosKolenberg\Enum;
4
5
abstract class EnumWithId extends Enum
6
{
7
    /**
8
     * The identifier for the instance.
9
     *
10
     * @var mixed
11
     */
12
    protected $id;
13
14
    /**
15
     * AbstractEnumWithId constructor.
16
     *
17
     * @param $id
18
     */
19 4
    public function __construct($id)
20
    {
21 4
        $this->id = $id;
22 2
    }
23
24
    /**
25
     * Get the id attribute.
26
     *
27
     * @return mixed
28
     */
29 2
    public function getId()
30
    {
31 2
        return $this->id;
32
    }
33
34
    /**
35
     * Return the name of the attribute which stores the identifier.
36
     *
37
     * @return mixed
38
     */
39 14
    protected function identifierAttribute()
40
    {
41 14
        return 'id';
42
    }
43
}
44