Completed
Push — master ( 75ec1b...02ab52 )
by Carlos C
02:40
created

Entry   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 39
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A value() 0 4 1
A index() 0 4 1
A equals() 0 4 2
A equalValue() 0 4 1
A equalIndex() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Eclipxe\Enum\Internal;
6
7
/**
8
 * This is where name, value and index is stored
9
 *
10
 * This is an internal class, do not use it by your own. Changes on this class are not library breaking changes.
11
 * @internal
12
 */
13
class Entry
14
{
15
    /** @var string */
16
    private $value;
17
18
    /** @var int */
19
    private $index;
20
21 5
    public function __construct(string $value, int $index)
22
    {
23 5
        $this->value = $value;
24 5
        $this->index = $index;
25 5
    }
26
27 16
    public function value(): string
28
    {
29 16
        return $this->value;
30
    }
31
32 21
    public function index(): int
33
    {
34 21
        return $this->index;
35
    }
36
37 7
    public function equals(self $other): bool
38
    {
39 7
        return ($this->equalValue($other->value()) && $this->equalIndex($other->index()));
40
    }
41
42 11
    public function equalValue(string $value): bool
43
    {
44 11
        return (0 === strcmp($this->value, $value));
45
    }
46
47 18
    public function equalIndex(int $index): bool
48
    {
49 18
        return ($this->index === $index);
50
    }
51
}
52