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