Passed
Push — master ( 56e86b...f388d7 )
by Paweł
03:35 queued 01:06
created

IntegerValue::__toString()   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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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