DayOff.php
5 years ago
Period.php
3 years ago
PeriodLocation.php
3 years ago
PeriodService.php
6 years ago
SpecialDay.php
6 years ago
SpecialDayPeriod.php
3 years ago
SpecialDayPeriodLocation.php
3 years ago
SpecialDayPeriodService.php
6 years ago
TimeOut.php
6 years ago
WeekDay.php
6 years ago
WeekDay.php
174 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\Schedule; |
| 8 | |
| 9 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 10 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; |
| 11 | use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; |
| 12 | use AmeliaBooking\Domain\Collection\Collection; |
| 13 | |
| 14 | /** |
| 15 | * Class WeekDay |
| 16 | * |
| 17 | * @package AmeliaBooking\Domain\Entity\Schedule |
| 18 | */ |
| 19 | class WeekDay |
| 20 | { |
| 21 | /** @var Id */ |
| 22 | private $id; |
| 23 | |
| 24 | /** @var IntegerValue */ |
| 25 | private $dayIndex; |
| 26 | |
| 27 | /** @var DateTimeValue */ |
| 28 | private $startTime; |
| 29 | |
| 30 | /** @var DateTimeValue */ |
| 31 | private $endTime; |
| 32 | |
| 33 | /** @var Collection */ |
| 34 | private $timeOutList; |
| 35 | |
| 36 | /** @var Collection */ |
| 37 | private $periodList; |
| 38 | |
| 39 | /** |
| 40 | * WeekDay constructor. |
| 41 | * |
| 42 | * @param IntegerValue $dayIndex |
| 43 | * @param DateTimeValue $startTime |
| 44 | * @param DateTimeValue $endTime |
| 45 | * @param Collection $timeOutList |
| 46 | * @param Collection $periodList |
| 47 | */ |
| 48 | public function __construct( |
| 49 | IntegerValue $dayIndex, |
| 50 | DateTimeValue $startTime, |
| 51 | DateTimeValue $endTime, |
| 52 | Collection $timeOutList, |
| 53 | Collection $periodList |
| 54 | ) { |
| 55 | $this->dayIndex = $dayIndex; |
| 56 | $this->startTime = $startTime; |
| 57 | $this->endTime = $endTime; |
| 58 | $this->timeOutList = $timeOutList; |
| 59 | $this->periodList = $periodList; |
| 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 IntegerValue |
| 80 | */ |
| 81 | public function getDayIndex() |
| 82 | { |
| 83 | return $this->dayIndex; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @param IntegerValue $dayIndex |
| 88 | */ |
| 89 | public function setDayIndex(IntegerValue $dayIndex) |
| 90 | { |
| 91 | $this->dayIndex = $dayIndex; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @return DateTimeValue |
| 96 | */ |
| 97 | public function getStartTime() |
| 98 | { |
| 99 | return $this->startTime; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * @param DateTimeValue $startTime |
| 104 | */ |
| 105 | public function setStartTime(DateTimeValue $startTime) |
| 106 | { |
| 107 | $this->startTime = $startTime; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @return DateTimeValue |
| 112 | */ |
| 113 | public function getEndTime() |
| 114 | { |
| 115 | return $this->endTime; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * @param DateTimeValue $endTime |
| 120 | */ |
| 121 | public function setEndTime(DateTimeValue $endTime) |
| 122 | { |
| 123 | $this->endTime = $endTime; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * @return Collection |
| 128 | */ |
| 129 | public function getTimeOutList() |
| 130 | { |
| 131 | return $this->timeOutList; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * @param Collection $timeOutList |
| 136 | */ |
| 137 | public function setTimeOutList(Collection $timeOutList) |
| 138 | { |
| 139 | $this->timeOutList = $timeOutList; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * @return Collection |
| 144 | */ |
| 145 | public function getPeriodList() |
| 146 | { |
| 147 | return $this->periodList; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * @param Collection $periodList |
| 152 | */ |
| 153 | public function setPeriodList(Collection $periodList) |
| 154 | { |
| 155 | $this->periodList = $periodList; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * @return array |
| 160 | */ |
| 161 | public function toArray() |
| 162 | { |
| 163 | return [ |
| 164 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 165 | 'dayIndex' => $this->dayIndex->getValue(), |
| 166 | 'startTime' => $this->startTime->getValue()->format('H:i:s'), |
| 167 | 'endTime' => $this->endTime->getValue()->format('H:i:s') === '00:00:00' ? |
| 168 | '24:00:00' : $this->endTime->getValue()->format('H:i:s'), |
| 169 | 'timeOutList' => $this->timeOutList->toArray(), |
| 170 | 'periodList' => $this->periodList->toArray(), |
| 171 | ]; |
| 172 | } |
| 173 | } |
| 174 |