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

IntegerValue   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 9
c 2
b 0
f 0
dl 0
loc 38
rs 10
ccs 9
cts 9
cp 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 3 1
A increaseBy() 0 5 1
A isGreaterThan() 0 3 1
A diff() 0 3 1
A __toString() 0 3 1
A increment() 0 5 1
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