DayOff.php
6 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
Period.php
173 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\Collection\Collection; |
| 10 | use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; |
| 11 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 12 | |
| 13 | /** |
| 14 | * Class Period |
| 15 | * |
| 16 | * @package AmeliaBooking\Domain\Entity\Schedule |
| 17 | */ |
| 18 | class Period |
| 19 | { |
| 20 | /** @var Id */ |
| 21 | private $id; |
| 22 | |
| 23 | /** @var DateTimeValue */ |
| 24 | private $startTime; |
| 25 | |
| 26 | /** @var DateTimeValue */ |
| 27 | private $endTime; |
| 28 | |
| 29 | /** @var Id */ |
| 30 | private $locationId; |
| 31 | |
| 32 | /** @var Collection */ |
| 33 | private $periodServiceList; |
| 34 | |
| 35 | /** @var Collection */ |
| 36 | private $periodLocationList; |
| 37 | |
| 38 | /** |
| 39 | * Period constructor. |
| 40 | * |
| 41 | * @param DateTimeValue $startTime |
| 42 | * @param DateTimeValue $endTime |
| 43 | * @param Collection $periodServiceList |
| 44 | * @param Collection $periodLocationList |
| 45 | */ |
| 46 | public function __construct( |
| 47 | DateTimeValue $startTime, |
| 48 | DateTimeValue $endTime, |
| 49 | Collection $periodServiceList, |
| 50 | Collection $periodLocationList |
| 51 | ) { |
| 52 | $this->startTime = $startTime; |
| 53 | |
| 54 | $this->endTime = $endTime; |
| 55 | |
| 56 | $this->periodServiceList = $periodServiceList; |
| 57 | |
| 58 | $this->periodLocationList = $periodLocationList; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @return Id |
| 63 | */ |
| 64 | public function getId() |
| 65 | { |
| 66 | return $this->id; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @param Id $id |
| 71 | */ |
| 72 | public function setId(Id $id) |
| 73 | { |
| 74 | $this->id = $id; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * @return DateTimeValue |
| 79 | */ |
| 80 | public function getStartTime() |
| 81 | { |
| 82 | return $this->startTime; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @param DateTimeValue $startTime |
| 87 | */ |
| 88 | public function setStartTime(DateTimeValue $startTime) |
| 89 | { |
| 90 | $this->startTime = $startTime; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @return DateTimeValue |
| 95 | */ |
| 96 | public function getEndTime() |
| 97 | { |
| 98 | return $this->endTime; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * @param DateTimeValue $endTime |
| 103 | */ |
| 104 | public function setEndTime(DateTimeValue $endTime) |
| 105 | { |
| 106 | $this->endTime = $endTime; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * @return Id |
| 111 | */ |
| 112 | public function getLocationId() |
| 113 | { |
| 114 | return $this->locationId; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @param Id $locationId |
| 119 | */ |
| 120 | public function setLocationId(Id $locationId) |
| 121 | { |
| 122 | $this->locationId = $locationId; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * @return Collection |
| 127 | */ |
| 128 | public function getPeriodServiceList() |
| 129 | { |
| 130 | return $this->periodServiceList; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * @param Collection $periodServiceList |
| 135 | */ |
| 136 | public function setPeriodServiceList(Collection $periodServiceList) |
| 137 | { |
| 138 | $this->periodServiceList = $periodServiceList; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * @return Collection |
| 143 | */ |
| 144 | public function getPeriodLocationList() |
| 145 | { |
| 146 | return $this->periodLocationList; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * @param Collection $periodLocationList |
| 151 | */ |
| 152 | public function setPeriodLocationList(Collection $periodLocationList) |
| 153 | { |
| 154 | $this->periodLocationList = $periodLocationList; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * @return array |
| 159 | */ |
| 160 | public function toArray() |
| 161 | { |
| 162 | return [ |
| 163 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 164 | 'startTime' => $this->startTime->getValue()->format('H:i:s'), |
| 165 | 'endTime' => $this->endTime->getValue()->format('H:i:s') === '00:00:00' ? |
| 166 | '24:00:00' : $this->endTime->getValue()->format('H:i:s'), |
| 167 | 'locationId' => $this->locationId ? $this->getLocationId()->getValue() : null, |
| 168 | 'periodServiceList' => $this->periodServiceList->toArray(), |
| 169 | 'periodLocationList' => $this->periodLocationList->toArray(), |
| 170 | ]; |
| 171 | } |
| 172 | } |
| 173 |