Passed
Push — master ( 56e86b...f388d7 )
by Paweł
03:35 queued 01:06
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
ccs 16
cts 16
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 3 1
A isGreaterThan() 0 3 1
A increaseBy() 0 5 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 12
    final public function __construct(
10
        protected int $value,
11 12
    ) {}
12
13 11
    public function get(): int
14
    {
15 11
        return $this->value;
16
    }
17
18 1
    public function isGreaterThan(self $value): bool
19
    {
20 1
        return $this->value > $value->get();
21
    }
22
23 1
    public function diff(self $value): static
24
    {
25 1
        return new static($this->value - $value->get());
26
    }
27
28 1
    public function increment(): static
29
    {
30 1
        $this->value += 1;
31
32 1
        return $this;
33
    }
34
35 1
    public function increaseBy(self $value): static
36
    {
37 1
        $this->value += $value->get();
38
39 1
        return $this;
40
    }
41
42 1
    public function __toString(): string
43
    {
44 1
        return (string) $this->value;
45
    }
46
}
47