Total Complexity | 4 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | abstract class FloatValueObject implements FloatValueObjectInterface |
||
11 | { |
||
12 | private $value; |
||
13 | |||
14 | /** |
||
15 | * @throws Exception if value is invalid |
||
16 | */ |
||
17 | public function __construct(float $value) |
||
18 | { |
||
19 | $this->guard($value); |
||
20 | $this->value = $value; |
||
21 | } |
||
22 | |||
23 | public function equals(FloatValueObjectInterface $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(): float |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @throws Exception if value is invalid |
||
38 | */ |
||
39 | abstract protected function guard(float $value): void; |
||
40 | } |
||
41 |