EnumWithCodeAndValue::getCode()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace JosKolenberg\Enum;
4
5
abstract class EnumWithCodeAndValue extends Enum
6
{
7
    /**
8
     * The code for the instance.
9
     *
10
     * @var mixed
11
     */
12
    protected $code;
13
14
    /**
15
     * The value for the instance.
16
     *
17
     * @var mixed
18
     */
19
    protected $value;
20
21
    /**
22
     * AbstractEnumWithIdAndName constructor.
23
     *
24
     * @param $code
25
     * @param $value
26
     */
27 2
    public function __construct($code, $value)
28
    {
29 2
        $this->code = $code;
30 2
        $this->value = $value;
31 1
    }
32
33
    /**
34
     * Get the code attribute.
35
     *
36
     * @return mixed
37
     */
38 2
    public function getCode()
39
    {
40 2
        return $this->code;
41
    }
42
43
    /**
44
     * Get the value attribute.
45
     *
46
     * @return mixed
47
     */
48 4
    public function getValue()
49
    {
50 4
        return $this->value;
51
    }
52
53
    /**
54
     * Return the name of the attribute which stores the identifier.
55
     *
56
     * @return mixed
57
     */
58 6
    protected function identifierAttribute()
59
    {
60 6
        return 'code';
61
    }
62
}
63