Passed
Push — master ( f388d7...367320 )
by Paweł
03:15
created

IntegerValue::equals()   A

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
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Shared;
6
7
class IntegerValue implements \Stringable
8
{
9 17
    final public function __construct(
10
        protected int $value,
11 17
    ) {}
12
13 16
    public function get(): int
14
    {
15 16
        return $this->value;
16
    }
17
18 1
    public function equals(self $value): bool
19
    {
20 1
        return $this->value === $value->get();
21
    }
22
23 5
    public function isGreaterThan(self $value): bool
24
    {
25 5
        return $this->value > $value->get();
26
    }
27
28 4
    public function isGreaterThanOrEqual(self $value): bool
29
    {
30 4
        return $this->value >= $value->get();
31
    }
32
33 1
    public function diff(self $value): static
34
    {
35 1
        return new static($this->value - $value->get());
36
    }
37
38 5
    public function increment(): static
39
    {
40 5
        $this->value += 1;
41
42 5
        return $this;
43
    }
44
45 5
    public function increaseBy(self $value): static
46
    {
47 5
        $this->value += $value->get();
48
49 5
        return $this;
50
    }
51
52 1
    public function __toString(): string
53
    {
54 1
        return (string) $this->value;
55
    }
56
}
57