GalleryImage.php
144 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\Entity\Gallery; |
| 4 | |
| 5 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; |
| 6 | use AmeliaBooking\Domain\ValueObjects\Picture; |
| 7 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 8 | use AmeliaBooking\Domain\ValueObjects\String\EntityType; |
| 9 | |
| 10 | /** |
| 11 | * Class GalleryImage |
| 12 | * |
| 13 | * @package AmeliaBooking\Domain\Entity\Gallery |
| 14 | */ |
| 15 | class GalleryImage |
| 16 | { |
| 17 | /** @var Id */ |
| 18 | private $id; |
| 19 | |
| 20 | /** @var Id */ |
| 21 | private $entityId; |
| 22 | |
| 23 | /** @var EntityType */ |
| 24 | private $entityType; |
| 25 | |
| 26 | /** @var Picture */ |
| 27 | private $picture; |
| 28 | |
| 29 | /** @var PositiveInteger */ |
| 30 | protected $position; |
| 31 | |
| 32 | /** |
| 33 | * GalleryImage constructor. |
| 34 | * |
| 35 | * @param EntityType $entityType |
| 36 | * @param Picture $picture |
| 37 | * @param PositiveInteger $position |
| 38 | */ |
| 39 | public function __construct( |
| 40 | EntityType $entityType, |
| 41 | Picture $picture, |
| 42 | PositiveInteger $position |
| 43 | ) { |
| 44 | $this->entityType = $entityType; |
| 45 | $this->picture = $picture; |
| 46 | $this->position = $position; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @return Id |
| 51 | */ |
| 52 | public function getId() |
| 53 | { |
| 54 | return $this->id; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * @param Id $id |
| 59 | */ |
| 60 | public function setId(Id $id) |
| 61 | { |
| 62 | $this->id = $id; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @return Id |
| 67 | */ |
| 68 | public function getEntityId() |
| 69 | { |
| 70 | return $this->entityId; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @param Id $entityId |
| 75 | */ |
| 76 | public function setEntityId(Id $entityId) |
| 77 | { |
| 78 | $this->entityId = $entityId; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return EntityType |
| 83 | */ |
| 84 | public function getEntityType() |
| 85 | { |
| 86 | return $this->entityType; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @param EntityType $entityType |
| 91 | */ |
| 92 | public function setEntityType(EntityType $entityType) |
| 93 | { |
| 94 | $this->entityType = $entityType; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * @return Picture |
| 99 | */ |
| 100 | public function getPicture() |
| 101 | { |
| 102 | return $this->picture; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @param Picture $picture |
| 107 | */ |
| 108 | public function setPicture(Picture $picture) |
| 109 | { |
| 110 | $this->picture = $picture; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @return PositiveInteger |
| 115 | */ |
| 116 | public function getPosition() |
| 117 | { |
| 118 | return $this->position; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @param PositiveInteger $position |
| 123 | */ |
| 124 | public function setPosition(PositiveInteger $position) |
| 125 | { |
| 126 | $this->position = $position; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @return array |
| 131 | */ |
| 132 | public function toArray() |
| 133 | { |
| 134 | return [ |
| 135 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 136 | 'entityId' => null !== $this->getEntityId() ? $this->getEntityId()->getValue() : null, |
| 137 | 'entityType' => null !== $this->getEntityType() ? $this->getEntityType()->getValue() : null, |
| 138 | 'pictureFullPath' => null !== $this->getPicture() ? $this->getPicture()->getFullPath() : null, |
| 139 | 'pictureThumbPath' => null !== $this->getPicture() ? $this->getPicture()->getThumbPath() : null, |
| 140 | 'position' => null !== $this->getPosition() ? $this->getPosition()->getValue() : null, |
| 141 | ]; |
| 142 | } |
| 143 | } |
| 144 |