| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | abstract class IntegerValueObject implements IntegerValueObjectInterface |
||
| 11 | { |
||
| 12 | private $value; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @throws Exception if value is invalid |
||
| 16 | */ |
||
| 17 | public function __construct(int $value) |
||
| 18 | { |
||
| 19 | $this->guard($value); |
||
| 20 | $this->value = $value; |
||
| 21 | } |
||
| 22 | |||
| 23 | public function equals(IntegerValueObjectInterface $other): bool |
||
| 24 | { |
||
| 25 | if (static::class !== get_class($other)) { |
||
| 26 | return false; |
||
| 27 | } |
||
| 28 | return $this->getValue() === $other->getValue(); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function getValue(): int |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @throws Exception if value is invalid |
||
| 38 | */ |
||
| 39 | abstract protected function guard(int $value): void; |
||
| 40 | } |
||
| 41 |