Coupon.php
316 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @copyright © TMS-Plugins. All rights reserved. |
| 4 | * @licence See LICENCE.md for license details. |
| 5 | */ |
| 6 | |
| 7 | namespace AmeliaBooking\Domain\Entity\Coupon; |
| 8 | |
| 9 | use AmeliaBooking\Domain\Collection\Collection; |
| 10 | use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; |
| 11 | use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; |
| 12 | use AmeliaBooking\Domain\ValueObjects\DiscountFixedValue; |
| 13 | use AmeliaBooking\Domain\ValueObjects\DiscountPercentageValue; |
| 14 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; |
| 15 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; |
| 16 | use AmeliaBooking\Domain\ValueObjects\String\CouponCode; |
| 17 | use AmeliaBooking\Domain\ValueObjects\String\Status; |
| 18 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 19 | |
| 20 | /** |
| 21 | * Class Coupon |
| 22 | * |
| 23 | * @package AmeliaBooking\Domain\Entity\Coupon |
| 24 | */ |
| 25 | class Coupon |
| 26 | { |
| 27 | /** @var Id */ |
| 28 | private $id; |
| 29 | |
| 30 | /** @var CouponCode */ |
| 31 | private $code; |
| 32 | |
| 33 | /** @var DiscountPercentageValue */ |
| 34 | private $discount; |
| 35 | |
| 36 | /** @var DiscountFixedValue */ |
| 37 | private $deduction; |
| 38 | |
| 39 | /** @var PositiveInteger */ |
| 40 | private $limit; |
| 41 | |
| 42 | /** @var WholeNumber */ |
| 43 | private $customerLimit; |
| 44 | |
| 45 | /** @var WholeNumber */ |
| 46 | private $used; |
| 47 | |
| 48 | /** @var WholeNumber */ |
| 49 | private $notificationInterval; |
| 50 | |
| 51 | /** @var BooleanValueObject */ |
| 52 | private $notificationRecurring; |
| 53 | |
| 54 | /** @var Status */ |
| 55 | private $status; |
| 56 | |
| 57 | /** @var Collection */ |
| 58 | private $serviceList; |
| 59 | |
| 60 | /** @var Collection */ |
| 61 | private $eventList; |
| 62 | |
| 63 | /** @var Collection */ |
| 64 | private $packageList; |
| 65 | |
| 66 | /** @var DateTimeValue */ |
| 67 | private $expirationDate; |
| 68 | |
| 69 | /** |
| 70 | * @return Id |
| 71 | */ |
| 72 | public function getId() |
| 73 | { |
| 74 | return $this->id; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * @param Id $id |
| 79 | */ |
| 80 | public function setId($id) |
| 81 | { |
| 82 | $this->id = $id; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @return CouponCode |
| 87 | */ |
| 88 | public function getCode() |
| 89 | { |
| 90 | return $this->code; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @param CouponCode $code |
| 95 | */ |
| 96 | public function setCode(CouponCode $code) |
| 97 | { |
| 98 | $this->code = $code; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * @return DiscountPercentageValue |
| 103 | */ |
| 104 | public function getDiscount() |
| 105 | { |
| 106 | return $this->discount; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * @param DiscountPercentageValue $discount |
| 111 | */ |
| 112 | public function setDiscount(DiscountPercentageValue $discount) |
| 113 | { |
| 114 | $this->discount = $discount; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @return DiscountFixedValue |
| 119 | */ |
| 120 | public function getDeduction() |
| 121 | { |
| 122 | return $this->deduction; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * @param DiscountFixedValue $deduction |
| 127 | */ |
| 128 | public function setDeduction(DiscountFixedValue $deduction) |
| 129 | { |
| 130 | $this->deduction = $deduction; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * @return PositiveInteger |
| 135 | */ |
| 136 | public function getLimit() |
| 137 | { |
| 138 | return $this->limit; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * @param PositiveInteger $limit |
| 143 | */ |
| 144 | public function setLimit($limit) |
| 145 | { |
| 146 | $this->limit = $limit; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * @return WholeNumber |
| 151 | */ |
| 152 | public function getCustomerLimit() |
| 153 | { |
| 154 | return $this->customerLimit; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * @param WholeNumber $customerLimit |
| 159 | */ |
| 160 | public function setCustomerLimit($customerLimit) |
| 161 | { |
| 162 | $this->customerLimit = $customerLimit; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * @return WholeNumber |
| 167 | */ |
| 168 | public function getUsed() |
| 169 | { |
| 170 | return $this->used; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * @param WholeNumber $used |
| 175 | */ |
| 176 | public function setUsed($used) |
| 177 | { |
| 178 | $this->used = $used; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * @return WholeNumber |
| 183 | */ |
| 184 | public function getNotificationInterval() |
| 185 | { |
| 186 | return $this->notificationInterval; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * @param WholeNumber $notificationInterval |
| 191 | */ |
| 192 | public function setNotificationInterval($notificationInterval) |
| 193 | { |
| 194 | $this->notificationInterval = $notificationInterval; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * @return BooleanValueObject |
| 199 | */ |
| 200 | public function getNotificationRecurring() |
| 201 | { |
| 202 | return $this->notificationRecurring; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * @param BooleanValueObject $notificationRecurring |
| 207 | */ |
| 208 | public function setNotificationRecurring($notificationRecurring) |
| 209 | { |
| 210 | $this->notificationRecurring = $notificationRecurring; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * @return Status |
| 215 | */ |
| 216 | public function getStatus() |
| 217 | { |
| 218 | return $this->status; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * @param Status $status |
| 223 | */ |
| 224 | public function setStatus(Status $status) |
| 225 | { |
| 226 | $this->status = $status; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * @return Collection |
| 231 | */ |
| 232 | public function getServiceList() |
| 233 | { |
| 234 | return $this->serviceList; |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * @param Collection $serviceList |
| 239 | */ |
| 240 | public function setServiceList(Collection $serviceList) |
| 241 | { |
| 242 | $this->serviceList = $serviceList; |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * @return Collection |
| 247 | */ |
| 248 | public function getEventList() |
| 249 | { |
| 250 | return $this->eventList; |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * @param Collection $eventList |
| 255 | */ |
| 256 | public function setEventList(Collection $eventList) |
| 257 | { |
| 258 | $this->eventList = $eventList; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * @return Collection |
| 263 | */ |
| 264 | public function getPackageList() |
| 265 | { |
| 266 | return $this->packageList; |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * @param Collection $packageList |
| 271 | */ |
| 272 | public function setPackageList(Collection $packageList) |
| 273 | { |
| 274 | $this->packageList = $packageList; |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * @return DateTimeValue |
| 279 | */ |
| 280 | public function getExpirationDate() |
| 281 | { |
| 282 | return $this->expirationDate; |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * @param DateTimeValue $expirationDate |
| 287 | */ |
| 288 | public function setExpirationDate(DateTimeValue $expirationDate) |
| 289 | { |
| 290 | $this->expirationDate = $expirationDate; |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * @return array |
| 295 | */ |
| 296 | public function toArray() |
| 297 | { |
| 298 | return [ |
| 299 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 300 | 'code' => $this->getCode() ? $this->getCode()->getValue() : null, |
| 301 | 'discount' => $this->getDiscount() ? $this->getDiscount()->getValue() : null, |
| 302 | 'deduction' => $this->getDeduction() ? $this->getDeduction()->getValue() : null, |
| 303 | 'limit' => $this->getLimit() ? $this->getLimit()->getValue() : null, |
| 304 | 'customerLimit' => $this->getCustomerLimit() ? $this->getCustomerLimit()->getValue() : 0, |
| 305 | 'used' => $this->getUsed() ? $this->getUsed()->getValue() : 0, |
| 306 | 'notificationInterval' => $this->getNotificationInterval() ? $this->getNotificationInterval()->getValue() : 0, |
| 307 | 'notificationRecurring' => $this->getNotificationRecurring() ? $this->getNotificationRecurring()->getValue() : 0, |
| 308 | 'status' => $this->getStatus() ? $this->getStatus()->getValue() : null, |
| 309 | 'serviceList' => $this->getServiceList() ? $this->getServiceList()->toArray() : [], |
| 310 | 'eventList' => $this->getEventList() ? $this->getEventList()->toArray() : [], |
| 311 | 'packageList' => $this->getPackageList() ? $this->getPackageList()->toArray() : [], |
| 312 | 'expirationDate' => $this->getExpirationDate() ? $this->getExpirationDate()->getValue()->format('Y-m-d') : null, |
| 313 | ]; |
| 314 | } |
| 315 | } |
| 316 |