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

IntegerValue   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 3 1
A increaseBy() 0 5 1
A isGreaterThanOrEqual() 0 3 1
A equals() 0 3 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 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