1 <?php
2
3 /* --------------------------------------------------------------
4 OrderItemAttribute.php 2015-10-27 gm
5 Gambio GmbH
6 http://www.gambio.de
7 Copyright (c) 2015 Gambio GmbH
8 Released under the GNU General Public License (Version 2)
9 [http://www.gnu.org/licenses/gpl-2.0.html]
10 --------------------------------------------------------------
11 */
12
13 MainFactory::load_class('OrderItemAttributeInterface');
14
15 /**
16 * Class OrderItemAttribute
17 *
18 * @category System
19 * @package Order
20 * @subpackage Entities
21 */
22 class OrderItemAttribute implements OrderItemAttributeInterface
23 {
24 /**
25 * Name.
26 *
27 * @var string
28 */
29 protected $name = '';
30
31 /**
32 * Value.
33 *
34 * @var string
35 */
36 protected $value = '';
37
38 /**
39 * Price.
40 *
41 * @var float
42 */
43 protected $price = 0.0;
44
45 /**
46 * Price type.
47 *
48 * @var string
49 */
50 protected $priceType = '';
51
52 /**
53 * Option ID.
54 *
55 * @var IdType
56 */
57 protected $optionId = 0;
58
59 /**
60 * Option value ID.
61 *
62 * @var IdType
63 */
64 protected $optionValueId = 0;
65
66
67 /**
68 * OrderItemAttribute constructor.
69 *
70 * @param StringType $name Order item attribute name.
71 * @param StringType $value Order item attribute value.
72 */
73 public function __construct(StringType $name, StringType $value)
74 {
75 $this->setName($name);
76 $this->setValue($value);
77 }
78
79
80 /**
81 * Returns the name of the order item attribute.
82 *
83 * @return string Name of the order item attribute.
84 */
85 public function getName()
86 {
87 return $this->name;
88 }
89
90
91 /**
92 * Returns the value of the order item attribute.
93 *
94 * @return string Value of the order item attribute.
95 */
96 public function getValue()
97 {
98 return $this->value;
99 }
100
101
102 /**
103 * Returns the price of the order item attribute.
104 *
105 * @return float Price of the order item attribute.
106 */
107 public function getPrice()
108 {
109 return $this->price;
110 }
111
112
113 /**
114 * Returns the price type of the order item attribute.
115 *
116 * @return string Price type of the order item attribute.
117 */
118 public function getPriceType()
119 {
120 return $this->priceType;
121 }
122
123
124 /**
125 * Returns the option ID.
126 *
127 * @return IdType Option ID.
128 */
129 public function getOptionId()
130 {
131 return $this->optionId;
132 }
133
134
135 /**
136 * Returns the option value ID.
137 *
138 * @return IdType Option value ID.
139 */
140 public function getOptionValueId()
141 {
142 return $this->optionValueId;
143 }
144
145
146 /**
147 * Sets the name of the order item attribute.
148 *
149 * @param StringType $name Name of the order item attribute.
150 *
151 * @return OrderItemAttribute Same instance for method chaining.
152 */
153 public function setName(StringType $name)
154 {
155 $this->name = $name->asString();
156
157 return $this;
158 }
159
160
161 /**
162 * Sets the value of the order item attribute.
163 *
164 * @param StringType $value Value of the order item attribute.
165 *
166 * @return OrderItemAttribute Same instance for method chaining.
167 */
168 public function setValue(StringType $value)
169 {
170 $this->value = $value->asString();
171
172 return $this;
173 }
174
175
176 /**
177 * Sets the price of the order item attribute.
178 *
179 * @param DecimalType $price Price of the order item attribute.
180 *
181 * @return OrderItemAttribute Same instance for method chaining.
182 */
183 public function setPrice(DecimalType $price)
184 {
185 $this->price = $price->asDecimal();
186
187 return $this;
188 }
189
190
191 /**
192 * Sets the price type of the order item attribute.
193 *
194 * @param StringType $priceType Price type of the order item attribute.
195 *
196 * @return OrderItemAttribute Same instance for method chaining.
197 */
198 public function setPriceType(StringType $priceType)
199 {
200 $this->priceType = $priceType->asString();
201
202 return $this;
203 }
204
205
206 /**
207 * Sets the option ID.
208 *
209 * @param IdType $optionId Option ID.
210 *
211 * @return OrderItemAttribute Same instance for method chaining.
212 */
213 public function setOptionId(IdType $optionId)
214 {
215 $this->optionId = $optionId->asInt();
216
217 return $this;
218 }
219
220
221 /**
222 * Set option value ID.
223 *
224 * @param IdType $optionValueId Option value ID.
225 *
226 * @return OrderItemAttribute Same instance for method chaining.
227 */
228 public function setOptionValueId(IdType $optionValueId)
229 {
230 $this->optionValueId = $optionValueId->asInt();
231
232 return $this;
233 }
234 }