DateTime
6 months ago
Number
6 months ago
String
1 month ago
BooleanValueObject.php
6 months ago
Discount.php
6 months ago
DiscountFixedValue.php
2 months ago
DiscountPercentageValue.php
6 months ago
Duration.php
7 years ago
Gender.php
1 year ago
GeoTag.php
7 years ago
Json.php
6 months ago
Picture.php
1 year ago
PositiveDuration.php
7 years ago
Priority.php
6 months ago
Recurring.php
4 years ago
Gender.php
45 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\ValueObjects; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; |
| 6 | |
| 7 | /** |
| 8 | * Class Gender |
| 9 | * |
| 10 | * @package AmeliaBooking\Domain\ValueObjects |
| 11 | */ |
| 12 | final class Gender |
| 13 | { |
| 14 | public const GENDER_MALE = 'male'; |
| 15 | public const GENDER_FEMALE = 'female'; |
| 16 | |
| 17 | /** |
| 18 | * @var string |
| 19 | */ |
| 20 | private $value; |
| 21 | |
| 22 | /** |
| 23 | * @param string $value |
| 24 | * |
| 25 | * @throws InvalidArgumentException |
| 26 | */ |
| 27 | public function __construct($value) |
| 28 | { |
| 29 | if (!in_array($value, [self::GENDER_MALE, self::GENDER_FEMALE, null], true)) { |
| 30 | throw new InvalidArgumentException('Not valid gender option'); |
| 31 | } |
| 32 | $this->value = $value; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Return the value from the value object |
| 37 | * |
| 38 | * @return string |
| 39 | */ |
| 40 | public function getValue() |
| 41 | { |
| 42 | return $this->value; |
| 43 | } |
| 44 | } |
| 45 |