Service
2 years ago
AbstractBookable.php
2 years ago
AbstractCategory.php
2 years ago
AbstractExtra.php
2 years ago
AbstractExtra.php
148 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\Entity\Bookable; |
| 4 | |
| 5 | use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; |
| 6 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 7 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; |
| 8 | use AmeliaBooking\Domain\ValueObjects\String\Description; |
| 9 | use AmeliaBooking\Domain\ValueObjects\String\Name; |
| 10 | |
| 11 | /** |
| 12 | * Class AbstractExtra |
| 13 | * |
| 14 | * @package AmeliaBooking\Domain\Entity\Bookable |
| 15 | */ |
| 16 | abstract class AbstractExtra |
| 17 | { |
| 18 | /** @var Id */ |
| 19 | private $id; |
| 20 | |
| 21 | /** @var Name */ |
| 22 | protected $name; |
| 23 | |
| 24 | /** @var Description */ |
| 25 | protected $description; |
| 26 | |
| 27 | /** @var Price */ |
| 28 | protected $price; |
| 29 | |
| 30 | /** @var PositiveInteger */ |
| 31 | protected $maxQuantity; |
| 32 | |
| 33 | /** @var PositiveInteger */ |
| 34 | protected $position; |
| 35 | |
| 36 | /** |
| 37 | * @return Id |
| 38 | */ |
| 39 | public function getId() |
| 40 | { |
| 41 | return $this->id; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @param Id $id |
| 46 | */ |
| 47 | public function setId(Id $id) |
| 48 | { |
| 49 | $this->id = $id; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @return Name |
| 54 | */ |
| 55 | public function getName() |
| 56 | { |
| 57 | return $this->name; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @param Name $name |
| 62 | */ |
| 63 | public function setName(Name $name) |
| 64 | { |
| 65 | $this->name = $name; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @return Description |
| 70 | */ |
| 71 | public function getDescription() |
| 72 | { |
| 73 | return $this->description; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @param Description $description |
| 78 | */ |
| 79 | public function setDescription(Description $description) |
| 80 | { |
| 81 | $this->description = $description; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @return Price |
| 86 | */ |
| 87 | public function getPrice() |
| 88 | { |
| 89 | return $this->price; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @param Price $price |
| 94 | */ |
| 95 | public function setPrice(Price $price) |
| 96 | { |
| 97 | $this->price = $price; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @return PositiveInteger |
| 102 | */ |
| 103 | public function getMaxQuantity() |
| 104 | { |
| 105 | return $this->maxQuantity; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @param PositiveInteger $maxQuantity |
| 110 | */ |
| 111 | public function setMaxQuantity(PositiveInteger $maxQuantity) |
| 112 | { |
| 113 | $this->maxQuantity = $maxQuantity; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * @return PositiveInteger |
| 118 | */ |
| 119 | public function getPosition() |
| 120 | { |
| 121 | return $this->position; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @param PositiveInteger $position |
| 126 | */ |
| 127 | public function setPosition(PositiveInteger $position) |
| 128 | { |
| 129 | $this->position = $position; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * @return array |
| 134 | */ |
| 135 | public function toArray() |
| 136 | { |
| 137 | return [ |
| 138 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 139 | 'name' => $this->getName() ? $this->getName()->getValue() : null, |
| 140 | 'description' => $this->getDescription() ? $this->getDescription()->getValue() : null, |
| 141 | 'price' => $this->getPrice() ? $this->getPrice()->getValue() : null, |
| 142 | 'maxQuantity' => $this->getMaxQuantity() ? $this->getMaxQuantity()->getValue() : null, |
| 143 | 'position' => $this->getPosition() ? $this->getPosition()->getValue() : null, |
| 144 | 'type' => $this->getType() ? $this->getType()->getValue() : null, |
| 145 | ]; |
| 146 | } |
| 147 | } |
| 148 |