Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
5 | class PositiveNumber |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var int |
||
10 | */ |
||
11 | private $value; |
||
12 | |||
13 | /** |
||
14 | * @param int $value |
||
15 | */ |
||
16 | public function __construct(int $value) |
||
17 | { |
||
18 | if ($value < 1) { |
||
19 | throw new \InvalidArgumentException( |
||
20 | 'Value has to be greater than 0, '.$value.' given.' |
||
21 | ); |
||
22 | } |
||
23 | $this->value = $value; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @return int |
||
28 | */ |
||
29 | public function toNative(): int |
||
30 | { |
||
31 | return $this->value; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param PositiveNumber $positiveNumber |
||
36 | * @return bool |
||
37 | */ |
||
38 | public function equals(PositiveNumber $positiveNumber): bool |
||
41 | } |
||
42 | } |
||
43 |