Capacity.php
7 years ago
DateRepeat.php
7 years ago
Id.php
7 years ago
IntegerValue.php
7 years ago
LoginType.php
6 years ago
PositiveInteger.php
7 years ago
Status.php
7 years ago
WholeNumber.php
3 years ago
WholeNumber.php
43 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\ValueObjects\Number\Integer; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; |
| 6 | |
| 7 | /** |
| 8 | * Class WholeNumber |
| 9 | * |
| 10 | * @package AmeliaBooking\Domain\ValueObjects\Number\Integer |
| 11 | */ |
| 12 | final class WholeNumber |
| 13 | { |
| 14 | /** |
| 15 | * @var string |
| 16 | */ |
| 17 | private $integer; |
| 18 | |
| 19 | /** |
| 20 | * @param string $integer |
| 21 | * |
| 22 | * @throws InvalidArgumentException |
| 23 | */ |
| 24 | public function __construct($integer) |
| 25 | { |
| 26 | if (filter_var($integer, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]) === false) { |
| 27 | throw new InvalidArgumentException("Number '$integer' must be integer"); |
| 28 | } |
| 29 | |
| 30 | $this->integer = (int)$integer; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Return the number from the value object |
| 35 | * |
| 36 | * @return int |
| 37 | */ |
| 38 | public function getValue() |
| 39 | { |
| 40 | return $this->integer; |
| 41 | } |
| 42 | } |
| 43 |