CustomFieldOption.php
145 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\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 Id $customFieldId |
| 41 | * @param Label $label |
| 42 | * @param IntegerValue $position |
| 43 | */ |
| 44 | public function __construct(Id $customFieldId, Label $label, IntegerValue $position) |
| 45 | { |
| 46 | $this->customFieldId = $customFieldId; |
| 47 | $this->label = $label; |
| 48 | $this->position = $position; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @return Id |
| 53 | */ |
| 54 | public function getId() |
| 55 | { |
| 56 | return $this->id; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @param Id $id |
| 61 | */ |
| 62 | public function setId($id) |
| 63 | { |
| 64 | $this->id = $id; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * @return Id |
| 69 | */ |
| 70 | public function getCustomFieldId() |
| 71 | { |
| 72 | return $this->customFieldId; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * @param Id $customFieldId |
| 77 | */ |
| 78 | public function setCustomFieldId($customFieldId) |
| 79 | { |
| 80 | $this->customFieldId = $customFieldId; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @return Label |
| 85 | */ |
| 86 | public function getLabel() |
| 87 | { |
| 88 | return $this->label; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @param Label $label |
| 93 | */ |
| 94 | public function setLabel($label) |
| 95 | { |
| 96 | $this->label = $label; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @return IntegerValue |
| 101 | */ |
| 102 | public function getPosition() |
| 103 | { |
| 104 | return $this->position; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * @param IntegerValue $position |
| 109 | */ |
| 110 | public function setPosition($position) |
| 111 | { |
| 112 | $this->position = $position; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * @return Json |
| 117 | */ |
| 118 | public function getTranslations() |
| 119 | { |
| 120 | return $this->translations; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * @param Json $translations |
| 125 | */ |
| 126 | public function setTranslations(Json $translations) |
| 127 | { |
| 128 | $this->translations = $translations; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * @return array |
| 133 | */ |
| 134 | public function toArray() |
| 135 | { |
| 136 | return [ |
| 137 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 138 | 'customFieldId' => $this->getCustomFieldId()->getValue(), |
| 139 | 'label' => $this->getLabel()->getValue(), |
| 140 | 'position' => $this->getPosition()->getValue(), |
| 141 | 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, |
| 142 | ]; |
| 143 | } |
| 144 | } |
| 145 |