Test Failed
Push — master ( 55d9e9...6ae951 )
by Paweł
02:43
created

IntegerValue::increment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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