Service
1 year ago
AbstractBookable.php
1 year ago
AbstractCategory.php
1 year ago
AbstractExtra.php
1 year ago
AbstractCategory.php
216 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\Bookable; |
| 9 | |
| 10 | use AmeliaBooking\Domain\Collection\Collection; |
| 11 | use AmeliaBooking\Domain\ValueObjects\Json; |
| 12 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 13 | use AmeliaBooking\Domain\ValueObjects\Picture; |
| 14 | use AmeliaBooking\Domain\ValueObjects\String\Color; |
| 15 | use AmeliaBooking\Domain\ValueObjects\String\Status; |
| 16 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; |
| 17 | use AmeliaBooking\Domain\ValueObjects\String\Name; |
| 18 | |
| 19 | /** |
| 20 | * Class AbstractCategory |
| 21 | * |
| 22 | * @package AmeliaBooking\Domain\Entity\Bookable |
| 23 | */ |
| 24 | abstract class AbstractCategory |
| 25 | { |
| 26 | /** @var Id */ |
| 27 | private $id; |
| 28 | |
| 29 | /** @var Status */ |
| 30 | protected $status; |
| 31 | |
| 32 | /** @var Name */ |
| 33 | protected $name; |
| 34 | |
| 35 | /** @var Collection */ |
| 36 | private $serviceList; |
| 37 | |
| 38 | /** @var PositiveInteger */ |
| 39 | protected $position; |
| 40 | |
| 41 | /** @var Json */ |
| 42 | protected $translations; |
| 43 | |
| 44 | /** @var Color */ |
| 45 | protected $color; |
| 46 | |
| 47 | /** @var Picture */ |
| 48 | protected $picture; |
| 49 | |
| 50 | /** |
| 51 | * AbstractCategory constructor. |
| 52 | * |
| 53 | * @param Status $status |
| 54 | * @param Name $name |
| 55 | * @param PositiveInteger $position |
| 56 | * @param Color $color |
| 57 | */ |
| 58 | public function __construct( |
| 59 | Status $status, |
| 60 | Name $name, |
| 61 | PositiveInteger $position, |
| 62 | Color $color |
| 63 | ) { |
| 64 | $this->status = $status; |
| 65 | $this->name = $name; |
| 66 | $this->position = $position; |
| 67 | $this->color = $color; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @return Id |
| 72 | */ |
| 73 | public function getId() |
| 74 | { |
| 75 | return $this->id; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @param Id $id |
| 80 | */ |
| 81 | public function setId(Id $id) |
| 82 | { |
| 83 | $this->id = $id; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @return Status |
| 88 | */ |
| 89 | public function getStatus() |
| 90 | { |
| 91 | return $this->status; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @param Status $status |
| 96 | */ |
| 97 | public function setStatus(Status $status) |
| 98 | { |
| 99 | $this->status = $status; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * @return Name |
| 104 | */ |
| 105 | public function getName() |
| 106 | { |
| 107 | return $this->name; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @param Name $name |
| 112 | */ |
| 113 | public function setName(Name $name) |
| 114 | { |
| 115 | $this->name = $name; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * @return Collection |
| 120 | */ |
| 121 | public function getServiceList() |
| 122 | { |
| 123 | return $this->serviceList; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * @param Collection $serviceList |
| 128 | */ |
| 129 | public function setServiceList(Collection $serviceList) |
| 130 | { |
| 131 | $this->serviceList = $serviceList; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * @return PositiveInteger |
| 136 | */ |
| 137 | public function getPosition() |
| 138 | { |
| 139 | return $this->position; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * @param PositiveInteger $position |
| 144 | */ |
| 145 | public function setPosition($position) |
| 146 | { |
| 147 | $this->position = $position; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * @return Json |
| 152 | */ |
| 153 | public function getTranslations() |
| 154 | { |
| 155 | return $this->translations; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * @param Json $translations |
| 160 | */ |
| 161 | public function setTranslations(Json $translations) |
| 162 | { |
| 163 | $this->translations = $translations; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * @return Color |
| 168 | */ |
| 169 | public function getColor() |
| 170 | { |
| 171 | return $this->color; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * @param Color $color |
| 176 | */ |
| 177 | public function setColor(Color $color) |
| 178 | { |
| 179 | $this->color = $color; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * @return Picture |
| 184 | */ |
| 185 | public function getPicture() |
| 186 | { |
| 187 | return $this->picture; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * @param Picture $picture |
| 192 | */ |
| 193 | public function setPicture(Picture $picture) |
| 194 | { |
| 195 | $this->picture = $picture; |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * @return array |
| 200 | */ |
| 201 | public function toArray() |
| 202 | { |
| 203 | return [ |
| 204 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 205 | 'status' => $this->getStatus()->getValue(), |
| 206 | 'name' => $this->getName()->getValue(), |
| 207 | 'serviceList' => $this->getServiceList() ? $this->getServiceList()->toArray() : [], |
| 208 | 'position' => $this->getPosition()->getValue(), |
| 209 | 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, |
| 210 | 'color' => null !== $this->getColor() ? $this->getColor()->getValue() : null, |
| 211 | 'pictureFullPath' => null !== $this->getPicture() ? $this->getPicture()->getFullPath() : null, |
| 212 | 'pictureThumbPath' => null !== $this->getPicture() ? $this->getPicture()->getThumbPath() : null, |
| 213 | ]; |
| 214 | } |
| 215 | } |
| 216 |