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