| Total Complexity | 10 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class IntegerValue implements \Stringable |
||
| 8 | { |
||
| 9 | 18 | final public function __construct( |
|
| 10 | protected int $value, |
||
| 11 | ) { |
||
| 12 | 18 | $this->validate(); |
|
| 13 | 17 | } |
|
| 14 | |||
| 15 | 16 | public function get(): int |
|
| 16 | { |
||
| 17 | 16 | return $this->value; |
|
| 18 | } |
||
| 19 | |||
| 20 | 3 | public function equals(self $value): bool |
|
| 21 | { |
||
| 22 | 3 | return $this->value === $value->get(); |
|
| 23 | } |
||
| 24 | |||
| 25 | 5 | public function isGreaterThan(self $value): bool |
|
| 26 | { |
||
| 27 | 5 | return $this->value > $value->get(); |
|
| 28 | } |
||
| 29 | |||
| 30 | 4 | public function isGreaterThanOrEqual(self $value): bool |
|
| 31 | { |
||
| 32 | 4 | return $this->value >= $value->get(); |
|
| 33 | } |
||
| 34 | |||
| 35 | 1 | public function diff(self $value): static |
|
| 36 | { |
||
| 37 | 1 | return new static($this->value - $value->get()); |
|
| 38 | } |
||
| 39 | |||
| 40 | 5 | public function increment(): static |
|
| 41 | { |
||
| 42 | 5 | $this->value += 1; |
|
| 43 | |||
| 44 | 5 | return $this; |
|
| 45 | } |
||
| 46 | |||
| 47 | 5 | public function increaseBy(self $value): static |
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | public function __toString(): string |
|
| 55 | { |
||
| 56 | 1 | return (string) $this->value; |
|
| 57 | } |
||
| 58 | |||
| 59 | 10 | protected function validate(): void |
|
| 61 | 10 | } |
|
| 62 | } |
||
| 63 |