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