Service
2 years ago
AbstractBookable.php
2 years ago
AbstractCategory.php
2 years ago
AbstractExtra.php
2 years ago
AbstractBookable.php
326 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @copyright © TMS-Plugins. All rights reserved. |
| 4 | * @licence See COPYING.md for license details. |
| 5 | */ |
| 6 | |
| 7 | namespace AmeliaBooking\Domain\Entity\Bookable; |
| 8 | |
| 9 | use AmeliaBooking\Domain\Collection\Collection; |
| 10 | use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; |
| 11 | use AmeliaBooking\Domain\ValueObjects\Json; |
| 12 | use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; |
| 13 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 14 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; |
| 15 | use AmeliaBooking\Domain\ValueObjects\Picture; |
| 16 | use AmeliaBooking\Domain\ValueObjects\String\BookableType; |
| 17 | use AmeliaBooking\Domain\ValueObjects\String\Color; |
| 18 | use AmeliaBooking\Domain\ValueObjects\String\DepositType; |
| 19 | use AmeliaBooking\Domain\ValueObjects\String\Description; |
| 20 | use AmeliaBooking\Domain\ValueObjects\String\Name; |
| 21 | |
| 22 | /** |
| 23 | * Class AbstractBookable |
| 24 | * |
| 25 | * @package AmeliaBooking\Domain\Entity\Bookable |
| 26 | */ |
| 27 | abstract class AbstractBookable |
| 28 | { |
| 29 | /** @var Id */ |
| 30 | private $id; |
| 31 | |
| 32 | /** @var Name */ |
| 33 | protected $name; |
| 34 | |
| 35 | /** @var Description */ |
| 36 | protected $description; |
| 37 | |
| 38 | /** @var Color */ |
| 39 | protected $color; |
| 40 | |
| 41 | /** @var DepositType */ |
| 42 | private $depositPayment; |
| 43 | |
| 44 | /** @var Price */ |
| 45 | protected $deposit; |
| 46 | |
| 47 | /** @var BooleanValueObject */ |
| 48 | protected $depositPerPerson; |
| 49 | |
| 50 | /** @var Price */ |
| 51 | protected $price; |
| 52 | |
| 53 | /** @var Picture */ |
| 54 | protected $picture; |
| 55 | |
| 56 | /** @var PositiveInteger */ |
| 57 | protected $position; |
| 58 | |
| 59 | /** @var Collection */ |
| 60 | private $extras; |
| 61 | |
| 62 | /** @var Collection */ |
| 63 | private $coupons; |
| 64 | |
| 65 | /** @var Json */ |
| 66 | private $settings; |
| 67 | |
| 68 | /** @var BooleanValueObject */ |
| 69 | protected $fullPayment; |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * @return Id |
| 74 | */ |
| 75 | public function getId() |
| 76 | { |
| 77 | return $this->id; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @param Id $id |
| 82 | */ |
| 83 | public function setId(Id $id) |
| 84 | { |
| 85 | $this->id = $id; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @return Name |
| 90 | */ |
| 91 | public function getName() |
| 92 | { |
| 93 | return $this->name; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * @param Name $name |
| 98 | */ |
| 99 | public function setName(Name $name) |
| 100 | { |
| 101 | $this->name = $name; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * @return Description |
| 106 | */ |
| 107 | public function getDescription() |
| 108 | { |
| 109 | return $this->description; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * @param Description $description |
| 114 | */ |
| 115 | public function setDescription(Description $description) |
| 116 | { |
| 117 | $this->description = $description; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * @return Color |
| 122 | */ |
| 123 | public function getColor() |
| 124 | { |
| 125 | return $this->color; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * @param Color $color |
| 130 | */ |
| 131 | public function setColor(Color $color) |
| 132 | { |
| 133 | $this->color = $color; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * @return Price |
| 138 | */ |
| 139 | public function getPrice() |
| 140 | { |
| 141 | return $this->price; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * @param Price $price |
| 146 | */ |
| 147 | public function setPrice(Price $price) |
| 148 | { |
| 149 | $this->price = $price; |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * @return Price |
| 154 | */ |
| 155 | public function getDeposit() |
| 156 | { |
| 157 | return $this->deposit; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * @param Price $deposit |
| 162 | */ |
| 163 | public function setDeposit(Price $deposit) |
| 164 | { |
| 165 | $this->deposit = $deposit; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * @return DepositType |
| 170 | */ |
| 171 | public function getDepositPayment() |
| 172 | { |
| 173 | return $this->depositPayment; |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * @param DepositType $depositPayment |
| 178 | */ |
| 179 | public function setDepositPayment(DepositType $depositPayment) |
| 180 | { |
| 181 | $this->depositPayment = $depositPayment; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * @return BooleanValueObject |
| 186 | */ |
| 187 | public function getDepositPerPerson() |
| 188 | { |
| 189 | return $this->depositPerPerson; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * @param BooleanValueObject $depositPerPerson |
| 194 | */ |
| 195 | public function setDepositPerPerson(BooleanValueObject $depositPerPerson) |
| 196 | { |
| 197 | $this->depositPerPerson = $depositPerPerson; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * @return Picture |
| 202 | */ |
| 203 | public function getPicture() |
| 204 | { |
| 205 | return $this->picture; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * @param Picture $picture |
| 210 | */ |
| 211 | public function setPicture(Picture $picture) |
| 212 | { |
| 213 | $this->picture = $picture; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * @return PositiveInteger |
| 218 | */ |
| 219 | public function getPosition() |
| 220 | { |
| 221 | return $this->position; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * @param PositiveInteger $position |
| 226 | */ |
| 227 | public function setPosition($position) |
| 228 | { |
| 229 | $this->position = $position; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * @return Collection |
| 234 | */ |
| 235 | public function getExtras() |
| 236 | { |
| 237 | return $this->extras; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * @param Collection $extras |
| 242 | */ |
| 243 | public function setExtras(Collection $extras) |
| 244 | { |
| 245 | $this->extras = $extras; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * @return Collection |
| 250 | */ |
| 251 | public function getCoupons() |
| 252 | { |
| 253 | return $this->coupons; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * @param Collection $coupons |
| 258 | */ |
| 259 | public function setCoupons(Collection $coupons) |
| 260 | { |
| 261 | $this->coupons = $coupons; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * @return Json |
| 266 | */ |
| 267 | public function getSettings() |
| 268 | { |
| 269 | return $this->settings; |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * @param Json $settings |
| 274 | */ |
| 275 | public function setSettings($settings) |
| 276 | { |
| 277 | $this->settings = $settings; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * @return BooleanValueObject |
| 282 | */ |
| 283 | public function getFullPayment() |
| 284 | { |
| 285 | return $this->fullPayment; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * @param BooleanValueObject $fullPayment |
| 290 | */ |
| 291 | public function setFullPayment(BooleanValueObject $fullPayment) |
| 292 | { |
| 293 | $this->fullPayment = $fullPayment; |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * @return BookableType |
| 298 | */ |
| 299 | abstract public function getType(); |
| 300 | |
| 301 | /** |
| 302 | * @return array |
| 303 | */ |
| 304 | public function toArray() |
| 305 | { |
| 306 | return [ |
| 307 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 308 | 'name' => null !== $this->getName() ? $this->getName()->getValue() : null, |
| 309 | 'description' => null !== $this->getDescription() ? $this->getDescription()->getValue() : null, |
| 310 | 'color' => null !== $this->getColor() ? $this->getColor()->getValue() : null, |
| 311 | 'price' => $this->getPrice() ? $this->getPrice()->getValue() : null, |
| 312 | 'deposit' => null !== $this->getDeposit() ? $this->getDeposit()->getValue() : null, |
| 313 | 'depositPayment' => null !== $this->getDepositPayment() ? $this->getDepositPayment()->getValue() : null, |
| 314 | 'depositPerPerson' => null !== $this->getDepositPerPerson() ? |
| 315 | $this->getDepositPerPerson()->getValue() : null, |
| 316 | 'pictureFullPath' => null !== $this->getPicture() ? $this->getPicture()->getFullPath() : null, |
| 317 | 'pictureThumbPath' => null !== $this->getPicture() ? $this->getPicture()->getThumbPath() : null, |
| 318 | 'extras' => $this->getExtras() ? $this->getExtras()->toArray() : [], |
| 319 | 'coupons' => $this->getCoupons() ? $this->getCoupons()->toArray() : [], |
| 320 | 'position' => null !== $this->getPosition() ? $this->getPosition()->getValue() : null, |
| 321 | 'settings' => null !== $this->getSettings() ? $this->getSettings()->getValue() : null, |
| 322 | 'fullPayment' => null !== $this->getFullPayment() ? $this->getFullPayment()->getValue() : null, |
| 323 | ]; |
| 324 | } |
| 325 | } |
| 326 |