BlockTime.php
2 months ago
DayOff.php
2 months ago
Period.php
6 months ago
PeriodLocation.php
6 months ago
PeriodService.php
6 months ago
SpecialDay.php
6 months ago
SpecialDayPeriod.php
6 months ago
SpecialDayPeriodLocation.php
6 months ago
SpecialDayPeriodService.php
6 months ago
TimeOut.php
6 months ago
WeekDay.php
6 months ago
DayOff.php
173 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @copyright © Melograno Ventures. All rights reserved. |
| 5 | * @licence See LICENCE.md for license details. |
| 6 | */ |
| 7 | |
| 8 | namespace AmeliaBooking\Domain\Entity\Schedule; |
| 9 | |
| 10 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 11 | use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; |
| 12 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\DateRepeat; |
| 13 | use AmeliaBooking\Domain\ValueObjects\String\DayOffType; |
| 14 | use AmeliaBooking\Domain\ValueObjects\String\Name; |
| 15 | |
| 16 | /** |
| 17 | * Class DayOff |
| 18 | * |
| 19 | * @package AmeliaBooking\Domain\Entity\Schedule |
| 20 | */ |
| 21 | class DayOff |
| 22 | { |
| 23 | /** @var Id */ |
| 24 | private $id; |
| 25 | |
| 26 | /** @var Name */ |
| 27 | private $name; |
| 28 | |
| 29 | /** @var DateTimeValue */ |
| 30 | private $startDate; |
| 31 | |
| 32 | /** @var DateTimeValue */ |
| 33 | private $endDate; |
| 34 | |
| 35 | /** @var DateRepeat */ |
| 36 | private $repeat; |
| 37 | |
| 38 | /** @var DayOffType */ |
| 39 | private $type; |
| 40 | |
| 41 | /** |
| 42 | * DayOff constructor. |
| 43 | * |
| 44 | * @param Name $name |
| 45 | * @param DateTimeValue $startDate |
| 46 | * @param DateTimeValue $endDate |
| 47 | * @param DateRepeat $repeat |
| 48 | */ |
| 49 | public function __construct( |
| 50 | Name $name, |
| 51 | DateTimeValue $startDate, |
| 52 | DateTimeValue $endDate, |
| 53 | DateRepeat $repeat |
| 54 | ) { |
| 55 | $this->name = $name; |
| 56 | $this->startDate = $startDate; |
| 57 | $this->endDate = $endDate; |
| 58 | $this->repeat = $repeat; |
| 59 | $this->type = new DayOffType(DayOffType::DAY_OFF); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @return Id |
| 64 | */ |
| 65 | public function getId() |
| 66 | { |
| 67 | return $this->id; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @param Id $id |
| 72 | */ |
| 73 | public function setId(Id $id) |
| 74 | { |
| 75 | $this->id = $id; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @return DateTimeValue |
| 80 | */ |
| 81 | public function getStartDate() |
| 82 | { |
| 83 | return $this->startDate; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @param DateTimeValue $startDate |
| 88 | */ |
| 89 | public function setStartDate(DateTimeValue $startDate) |
| 90 | { |
| 91 | $this->startDate = $startDate; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @return DateTimeValue |
| 96 | */ |
| 97 | public function getEndDate() |
| 98 | { |
| 99 | return $this->endDate; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * @param DateTimeValue $endDate |
| 104 | */ |
| 105 | public function setEndDate(DateTimeValue $endDate) |
| 106 | { |
| 107 | $this->endDate = $endDate; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @return DateRepeat |
| 112 | */ |
| 113 | public function getRepeat() |
| 114 | { |
| 115 | return $this->repeat; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * @param DateRepeat $repeat |
| 120 | */ |
| 121 | public function setRepeat(DateRepeat $repeat) |
| 122 | { |
| 123 | $this->repeat = $repeat; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * @return Name |
| 128 | */ |
| 129 | public function getName() |
| 130 | { |
| 131 | return $this->name; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * @param Name $name |
| 136 | */ |
| 137 | public function setName(Name $name) |
| 138 | { |
| 139 | $this->name = $name; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * @return DayOffType |
| 144 | */ |
| 145 | public function getType(): DayOffType |
| 146 | { |
| 147 | return $this->type; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * @param DayOffType $type |
| 152 | */ |
| 153 | public function setType(DayOffType $type) |
| 154 | { |
| 155 | $this->type = $type; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * @return array |
| 160 | */ |
| 161 | public function toArray() |
| 162 | { |
| 163 | return [ |
| 164 | 'id' => null !== $this->id ? $this->id->getValue() : null, |
| 165 | 'name' => $this->name->getValue(), |
| 166 | 'startDate' => $this->startDate->getValue()->format('Y-m-d'), |
| 167 | 'endDate' => $this->endDate->getValue()->format('Y-m-d'), |
| 168 | 'repeat' => $this->repeat->getValue(), |
| 169 | 'type' => $this->type->getValue(), |
| 170 | ]; |
| 171 | } |
| 172 | } |
| 173 |