EnumWithCodeAndValue   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A getCode() 0 3 1
A __construct() 0 4 1
A identifierAttribute() 0 3 1
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