CustomFieldOption.php
143 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @copyright © Melograno Ventures. All rights reserved. |
| 5 | * @licence See LICENCE.md for license details. |
| 6 | */ |
| 7 | |
| 8 | namespace AmeliaBooking\Domain\Entity\CustomField; |
| 9 | |
| 10 | use AmeliaBooking\Domain\ValueObjects\Json; |
| 11 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 12 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; |
| 13 | use AmeliaBooking\Domain\ValueObjects\String\Label; |
| 14 | |
| 15 | /** |
| 16 | * Class CustomFieldOption |
| 17 | * |
| 18 | * @package AmeliaBooking\Domain\Entity\CustomField |
| 19 | */ |
| 20 | class CustomFieldOption |
| 21 | { |
| 22 | /** @var Id */ |
| 23 | private $id; |
| 24 | |
| 25 | /** @var Id */ |
| 26 | private $customFieldId; |
| 27 | |
| 28 | /** @var Label */ |
| 29 | private $label; |
| 30 | |
| 31 | /** @var IntegerValue */ |
| 32 | private $position; |
| 33 | |
| 34 | /** @var Json */ |
| 35 | private $translations; |
| 36 | |
| 37 | /** |
| 38 | * CustomFieldOption constructor. |
| 39 | * |
| 40 | * @param Label $label |
| 41 | * @param IntegerValue $position |
| 42 | */ |
| 43 | public function __construct(Label $label, IntegerValue $position) |
| 44 | { |
| 45 | $this->label = $label; |
| 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) |
| 61 | { |
| 62 | $this->id = $id; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @return Id |
| 67 | */ |
| 68 | public function getCustomFieldId() |
| 69 | { |
| 70 | return $this->customFieldId; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @param Id $customFieldId |
| 75 | */ |
| 76 | public function setCustomFieldId($customFieldId) |
| 77 | { |
| 78 | $this->customFieldId = $customFieldId; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return Label |
| 83 | */ |
| 84 | public function getLabel() |
| 85 | { |
| 86 | return $this->label; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @param Label $label |
| 91 | */ |
| 92 | public function setLabel($label) |
| 93 | { |
| 94 | $this->label = $label; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * @return IntegerValue |
| 99 | */ |
| 100 | public function getPosition() |
| 101 | { |
| 102 | return $this->position; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @param IntegerValue $position |
| 107 | */ |
| 108 | public function setPosition($position) |
| 109 | { |
| 110 | $this->position = $position; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @return Json |
| 115 | */ |
| 116 | public function getTranslations() |
| 117 | { |
| 118 | return $this->translations; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @param Json $translations |
| 123 | */ |
| 124 | public function setTranslations(Json $translations) |
| 125 | { |
| 126 | $this->translations = $translations; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @return array |
| 131 | */ |
| 132 | public function toArray() |
| 133 | { |
| 134 | return [ |
| 135 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 136 | 'customFieldId' => $this->getCustomFieldId() ? $this->getCustomFieldId()->getValue() : null, |
| 137 | 'label' => $this->getLabel()->getValue(), |
| 138 | 'position' => $this->getPosition()->getValue(), |
| 139 | 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, |
| 140 | ]; |
| 141 | } |
| 142 | } |
| 143 |