Total Complexity | 95 |
Total Lines | 727 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like InvoiceItemType often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use InvoiceItemType, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class InvoiceItemType extends AbstractStructBase |
||
15 | { |
||
16 | /** |
||
17 | * The Name |
||
18 | * Meta information extracted from the WSDL |
||
19 | * - documentation: a human readable item nameOptional Character length and limits: 127 single-byte characters |
||
20 | * - maxOccurs: 1 |
||
21 | * - minOccurs: 0 |
||
22 | * @var string |
||
23 | */ |
||
24 | public $Name; |
||
25 | /** |
||
26 | * The Description |
||
27 | * Meta information extracted from the WSDL |
||
28 | * - documentation: a human readable item descriptionOptional Character length and limits: 127 single-byte characters |
||
29 | * - maxOccurs: 1 |
||
30 | * - minOccurs: 0 |
||
31 | * @var string |
||
32 | */ |
||
33 | public $Description; |
||
34 | /** |
||
35 | * The EAN |
||
36 | * Meta information extracted from the WSDL |
||
37 | * - documentation: The International Article Number or Universal Product Code (UPC) for the item. Empty string is allowed. Character length and limits: 17 single-byte characters |
||
38 | * - maxOccurs: 1 |
||
39 | * - minOccurs: 0 |
||
40 | * @var string |
||
41 | */ |
||
42 | public $EAN; |
||
43 | /** |
||
44 | * The SKU |
||
45 | * Meta information extracted from the WSDL |
||
46 | * - documentation: The Stock-Keeping Unit or other identification code assigned to the item. Character length and limits: 64 single-byte characters |
||
47 | * - maxOccurs: 1 |
||
48 | * - minOccurs: 0 |
||
49 | * @var string |
||
50 | */ |
||
51 | public $SKU; |
||
52 | /** |
||
53 | * The ReturnPolicyIdentifier |
||
54 | * Meta information extracted from the WSDL |
||
55 | * - documentation: A retailer could apply different return policies on different items. Each return policy would be identified using a label or identifier. This return policy identifier should be set here. This identifier will be displayed next to the |
||
56 | * item in the e-Receipt. Character length and limits: 8 single-byte characters |
||
57 | * - maxOccurs: 1 |
||
58 | * - minOccurs: 0 |
||
59 | * @var string |
||
60 | */ |
||
61 | public $ReturnPolicyIdentifier; |
||
62 | /** |
||
63 | * The Price |
||
64 | * Meta information extracted from the WSDL |
||
65 | * - documentation: total price of this item |
||
66 | * - maxOccurs: 1 |
||
67 | * - minOccurs: 0 |
||
68 | * @var \PayPal\StructType\BasicAmountType |
||
69 | */ |
||
70 | public $Price; |
||
71 | /** |
||
72 | * The ItemPrice |
||
73 | * Meta information extracted from the WSDL |
||
74 | * - documentation: price per item quantity |
||
75 | * - maxOccurs: 1 |
||
76 | * - minOccurs: 0 |
||
77 | * @var \PayPal\StructType\BasicAmountType |
||
78 | */ |
||
79 | public $ItemPrice; |
||
80 | /** |
||
81 | * The ItemCount |
||
82 | * Meta information extracted from the WSDL |
||
83 | * - documentation: quantity of the item (non-negative) |
||
84 | * - maxOccurs: 1 |
||
85 | * - minOccurs: 0 |
||
86 | * @var float |
||
87 | */ |
||
88 | public $ItemCount; |
||
89 | /** |
||
90 | * The ItemCountUnit |
||
91 | * Meta information extracted from the WSDL |
||
92 | * - documentation: Unit of measure for the itemCount |
||
93 | * - maxOccurs: 1 |
||
94 | * - minOccurs: 0 |
||
95 | * @var string |
||
96 | */ |
||
97 | public $ItemCountUnit; |
||
98 | /** |
||
99 | * The Discount |
||
100 | * Meta information extracted from the WSDL |
||
101 | * - documentation: discount applied to this item |
||
102 | * - maxOccurs: unbounded |
||
103 | * - minOccurs: 0 |
||
104 | * @var \PayPal\StructType\DiscountType[] |
||
105 | */ |
||
106 | public $Discount; |
||
107 | /** |
||
108 | * The Taxable |
||
109 | * Meta information extracted from the WSDL |
||
110 | * - documentation: identifies whether this item is taxable or not. If not passed, this will be assumed to be true. |
||
111 | * - maxOccurs: 1 |
||
112 | * - minOccurs: 0 |
||
113 | * @var bool |
||
114 | */ |
||
115 | public $Taxable; |
||
116 | /** |
||
117 | * The TaxRate |
||
118 | * Meta information extracted from the WSDL |
||
119 | * - documentation: The tax percentage applied to the item. This is only used for displaying in the receipt, it is not used in pricing calculations. Note: we have totalTax at invoice level. It's up to the caller to do the calculations for setting that |
||
120 | * other element. |
||
121 | * - maxOccurs: 1 |
||
122 | * - minOccurs: 0 |
||
123 | * @var float |
||
124 | */ |
||
125 | public $TaxRate; |
||
126 | /** |
||
127 | * The AdditionalFees |
||
128 | * Meta information extracted from the WSDL |
||
129 | * - documentation: Additional fees to this item |
||
130 | * - maxOccurs: unbounded |
||
131 | * - minOccurs: 0 |
||
132 | * @var \PayPal\StructType\AdditionalFeeType[] |
||
133 | */ |
||
134 | public $AdditionalFees; |
||
135 | /** |
||
136 | * The Reimbursable |
||
137 | * Meta information extracted from the WSDL |
||
138 | * - documentation: identifies whether this is reimbursable or not. If not pass, this will be assumed to be true. |
||
139 | * - maxOccurs: 1 |
||
140 | * - minOccurs: 0 |
||
141 | * @var bool |
||
142 | */ |
||
143 | public $Reimbursable; |
||
144 | /** |
||
145 | * The MPN |
||
146 | * Meta information extracted from the WSDL |
||
147 | * - documentation: Manufacturer part number. |
||
148 | * - maxOccurs: 1 |
||
149 | * - minOccurs: 0 |
||
150 | * @var string |
||
151 | */ |
||
152 | public $MPN; |
||
153 | /** |
||
154 | * The ISBN |
||
155 | * Meta information extracted from the WSDL |
||
156 | * - documentation: International Standard Book Number. Reference http://en.wikipedia.org/wiki/ISBN Character length and limits: 32 single-byte characters |
||
157 | * - maxOccurs: 1 |
||
158 | * - minOccurs: 0 |
||
159 | * @var string |
||
160 | */ |
||
161 | public $ISBN; |
||
162 | /** |
||
163 | * The PLU |
||
164 | * Meta information extracted from the WSDL |
||
165 | * - documentation: Price Look-Up code Reference http://en.wikipedia.org/wiki/Price_Look-Up_code Character length and limits: 5 single-byte characters |
||
166 | * - maxOccurs: 1 |
||
167 | * - minOccurs: 0 |
||
168 | * @var string |
||
169 | */ |
||
170 | public $PLU; |
||
171 | /** |
||
172 | * The ModelNumber |
||
173 | * Meta information extracted from the WSDL |
||
174 | * - documentation: Character length and limits: 32 single-byte characters |
||
175 | * - maxOccurs: 1 |
||
176 | * - minOccurs: 0 |
||
177 | * @var string |
||
178 | */ |
||
179 | public $ModelNumber; |
||
180 | /** |
||
181 | * The StyleNumber |
||
182 | * Meta information extracted from the WSDL |
||
183 | * - documentation: Character length and limits: 32 single-byte characters |
||
184 | * - maxOccurs: 1 |
||
185 | * - minOccurs: 0 |
||
186 | * @var string |
||
187 | */ |
||
188 | public $StyleNumber; |
||
189 | /** |
||
190 | * Constructor method for InvoiceItemType |
||
191 | * @uses InvoiceItemType::setName() |
||
192 | * @uses InvoiceItemType::setDescription() |
||
193 | * @uses InvoiceItemType::setEAN() |
||
194 | * @uses InvoiceItemType::setSKU() |
||
195 | * @uses InvoiceItemType::setReturnPolicyIdentifier() |
||
196 | * @uses InvoiceItemType::setPrice() |
||
197 | * @uses InvoiceItemType::setItemPrice() |
||
198 | * @uses InvoiceItemType::setItemCount() |
||
199 | * @uses InvoiceItemType::setItemCountUnit() |
||
200 | * @uses InvoiceItemType::setDiscount() |
||
201 | * @uses InvoiceItemType::setTaxable() |
||
202 | * @uses InvoiceItemType::setTaxRate() |
||
203 | * @uses InvoiceItemType::setAdditionalFees() |
||
204 | * @uses InvoiceItemType::setReimbursable() |
||
205 | * @uses InvoiceItemType::setMPN() |
||
206 | * @uses InvoiceItemType::setISBN() |
||
207 | * @uses InvoiceItemType::setPLU() |
||
208 | * @uses InvoiceItemType::setModelNumber() |
||
209 | * @uses InvoiceItemType::setStyleNumber() |
||
210 | * @param string $name |
||
211 | * @param string $description |
||
212 | * @param string $eAN |
||
213 | * @param string $sKU |
||
214 | * @param string $returnPolicyIdentifier |
||
215 | * @param \PayPal\StructType\BasicAmountType $price |
||
216 | * @param \PayPal\StructType\BasicAmountType $itemPrice |
||
217 | * @param float $itemCount |
||
218 | * @param string $itemCountUnit |
||
219 | * @param \PayPal\StructType\DiscountType[] $discount |
||
220 | * @param bool $taxable |
||
221 | * @param float $taxRate |
||
222 | * @param \PayPal\StructType\AdditionalFeeType[] $additionalFees |
||
223 | * @param bool $reimbursable |
||
224 | * @param string $mPN |
||
225 | * @param string $iSBN |
||
226 | * @param string $pLU |
||
227 | * @param string $modelNumber |
||
228 | * @param string $styleNumber |
||
229 | */ |
||
230 | public function __construct($name = null, $description = null, $eAN = null, $sKU = null, $returnPolicyIdentifier = null, \PayPal\StructType\BasicAmountType $price = null, \PayPal\StructType\BasicAmountType $itemPrice = null, $itemCount = null, $itemCountUnit = null, array $discount = array(), $taxable = null, $taxRate = null, array $additionalFees = array(), $reimbursable = null, $mPN = null, $iSBN = null, $pLU = null, $modelNumber = null, $styleNumber = null) |
||
231 | { |
||
232 | $this |
||
233 | ->setName($name) |
||
234 | ->setDescription($description) |
||
235 | ->setEAN($eAN) |
||
236 | ->setSKU($sKU) |
||
237 | ->setReturnPolicyIdentifier($returnPolicyIdentifier) |
||
238 | ->setPrice($price) |
||
239 | ->setItemPrice($itemPrice) |
||
240 | ->setItemCount($itemCount) |
||
241 | ->setItemCountUnit($itemCountUnit) |
||
242 | ->setDiscount($discount) |
||
243 | ->setTaxable($taxable) |
||
244 | ->setTaxRate($taxRate) |
||
245 | ->setAdditionalFees($additionalFees) |
||
246 | ->setReimbursable($reimbursable) |
||
247 | ->setMPN($mPN) |
||
248 | ->setISBN($iSBN) |
||
249 | ->setPLU($pLU) |
||
250 | ->setModelNumber($modelNumber) |
||
251 | ->setStyleNumber($styleNumber); |
||
252 | } |
||
253 | /** |
||
254 | * Get Name value |
||
255 | * @return string|null |
||
256 | */ |
||
257 | public function getName() |
||
258 | { |
||
259 | return $this->Name; |
||
260 | } |
||
261 | /** |
||
262 | * Set Name value |
||
263 | * @param string $name |
||
264 | * @return \PayPal\StructType\InvoiceItemType |
||
265 | */ |
||
266 | public function setName($name = null) |
||
267 | { |
||
268 | // validation for constraint: string |
||
269 | if (!is_null($name) && !is_string($name)) { |
||
|
|||
270 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($name, true), gettype($name)), __LINE__); |
||
271 | } |
||
272 | $this->Name = $name; |
||
273 | return $this; |
||
274 | } |
||
275 | /** |
||
276 | * Get Description value |
||
277 | * @return string|null |
||
278 | */ |
||
279 | public function getDescription() |
||
280 | { |
||
281 | return $this->Description; |
||
282 | } |
||
283 | /** |
||
284 | * Set Description value |
||
285 | * @param string $description |
||
286 | * @return \PayPal\StructType\InvoiceItemType |
||
287 | */ |
||
288 | public function setDescription($description = null) |
||
289 | { |
||
290 | // validation for constraint: string |
||
291 | if (!is_null($description) && !is_string($description)) { |
||
292 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($description, true), gettype($description)), __LINE__); |
||
293 | } |
||
294 | $this->Description = $description; |
||
295 | return $this; |
||
296 | } |
||
297 | /** |
||
298 | * Get EAN value |
||
299 | * @return string|null |
||
300 | */ |
||
301 | public function getEAN() |
||
302 | { |
||
303 | return $this->EAN; |
||
304 | } |
||
305 | /** |
||
306 | * Set EAN value |
||
307 | * @param string $eAN |
||
308 | * @return \PayPal\StructType\InvoiceItemType |
||
309 | */ |
||
310 | public function setEAN($eAN = null) |
||
311 | { |
||
312 | // validation for constraint: string |
||
313 | if (!is_null($eAN) && !is_string($eAN)) { |
||
314 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($eAN, true), gettype($eAN)), __LINE__); |
||
315 | } |
||
316 | $this->EAN = $eAN; |
||
317 | return $this; |
||
318 | } |
||
319 | /** |
||
320 | * Get SKU value |
||
321 | * @return string|null |
||
322 | */ |
||
323 | public function getSKU() |
||
324 | { |
||
325 | return $this->SKU; |
||
326 | } |
||
327 | /** |
||
328 | * Set SKU value |
||
329 | * @param string $sKU |
||
330 | * @return \PayPal\StructType\InvoiceItemType |
||
331 | */ |
||
332 | public function setSKU($sKU = null) |
||
333 | { |
||
334 | // validation for constraint: string |
||
335 | if (!is_null($sKU) && !is_string($sKU)) { |
||
336 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($sKU, true), gettype($sKU)), __LINE__); |
||
337 | } |
||
338 | $this->SKU = $sKU; |
||
339 | return $this; |
||
340 | } |
||
341 | /** |
||
342 | * Get ReturnPolicyIdentifier value |
||
343 | * @return string|null |
||
344 | */ |
||
345 | public function getReturnPolicyIdentifier() |
||
346 | { |
||
347 | return $this->ReturnPolicyIdentifier; |
||
348 | } |
||
349 | /** |
||
350 | * Set ReturnPolicyIdentifier value |
||
351 | * @param string $returnPolicyIdentifier |
||
352 | * @return \PayPal\StructType\InvoiceItemType |
||
353 | */ |
||
354 | public function setReturnPolicyIdentifier($returnPolicyIdentifier = null) |
||
355 | { |
||
356 | // validation for constraint: string |
||
357 | if (!is_null($returnPolicyIdentifier) && !is_string($returnPolicyIdentifier)) { |
||
358 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($returnPolicyIdentifier, true), gettype($returnPolicyIdentifier)), __LINE__); |
||
359 | } |
||
360 | $this->ReturnPolicyIdentifier = $returnPolicyIdentifier; |
||
361 | return $this; |
||
362 | } |
||
363 | /** |
||
364 | * Get Price value |
||
365 | * @return \PayPal\StructType\BasicAmountType|null |
||
366 | */ |
||
367 | public function getPrice() |
||
370 | } |
||
371 | /** |
||
372 | * Set Price value |
||
373 | * @param \PayPal\StructType\BasicAmountType $price |
||
374 | * @return \PayPal\StructType\InvoiceItemType |
||
375 | */ |
||
376 | public function setPrice(\PayPal\StructType\BasicAmountType $price = null) |
||
377 | { |
||
378 | $this->Price = $price; |
||
379 | return $this; |
||
380 | } |
||
381 | /** |
||
382 | * Get ItemPrice value |
||
383 | * @return \PayPal\StructType\BasicAmountType|null |
||
384 | */ |
||
385 | public function getItemPrice() |
||
386 | { |
||
387 | return $this->ItemPrice; |
||
388 | } |
||
389 | /** |
||
390 | * Set ItemPrice value |
||
391 | * @param \PayPal\StructType\BasicAmountType $itemPrice |
||
392 | * @return \PayPal\StructType\InvoiceItemType |
||
393 | */ |
||
394 | public function setItemPrice(\PayPal\StructType\BasicAmountType $itemPrice = null) |
||
398 | } |
||
399 | /** |
||
400 | * Get ItemCount value |
||
401 | * @return float|null |
||
402 | */ |
||
403 | public function getItemCount() |
||
404 | { |
||
405 | return $this->ItemCount; |
||
406 | } |
||
407 | /** |
||
408 | * Set ItemCount value |
||
409 | * @param float $itemCount |
||
410 | * @return \PayPal\StructType\InvoiceItemType |
||
411 | */ |
||
412 | public function setItemCount($itemCount = null) |
||
413 | { |
||
414 | // validation for constraint: float |
||
415 | if (!is_null($itemCount) && !(is_float($itemCount) || is_numeric($itemCount))) { |
||
416 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a float value, %s given', var_export($itemCount, true), gettype($itemCount)), __LINE__); |
||
417 | } |
||
418 | $this->ItemCount = $itemCount; |
||
419 | return $this; |
||
420 | } |
||
421 | /** |
||
422 | * Get ItemCountUnit value |
||
423 | * @return string|null |
||
424 | */ |
||
425 | public function getItemCountUnit() |
||
426 | { |
||
427 | return $this->ItemCountUnit; |
||
428 | } |
||
429 | /** |
||
430 | * Set ItemCountUnit value |
||
431 | * @uses \PayPal\EnumType\UnitOfMeasure::valueIsValid() |
||
432 | * @uses \PayPal\EnumType\UnitOfMeasure::getValidValues() |
||
433 | * @throws \InvalidArgumentException |
||
434 | * @param string $itemCountUnit |
||
435 | * @return \PayPal\StructType\InvoiceItemType |
||
436 | */ |
||
437 | public function setItemCountUnit($itemCountUnit = null) |
||
438 | { |
||
439 | // validation for constraint: enumeration |
||
440 | if (!\PayPal\EnumType\UnitOfMeasure::valueIsValid($itemCountUnit)) { |
||
441 | throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \PayPal\EnumType\UnitOfMeasure', is_array($itemCountUnit) ? implode(', ', $itemCountUnit) : var_export($itemCountUnit, true), implode(', ', \PayPal\EnumType\UnitOfMeasure::getValidValues())), __LINE__); |
||
442 | } |
||
443 | $this->ItemCountUnit = $itemCountUnit; |
||
444 | return $this; |
||
445 | } |
||
446 | /** |
||
447 | * Get Discount value |
||
448 | * @return \PayPal\StructType\DiscountType[]|null |
||
449 | */ |
||
450 | public function getDiscount() |
||
451 | { |
||
452 | return $this->Discount; |
||
453 | } |
||
454 | /** |
||
455 | * This method is responsible for validating the values passed to the setDiscount method |
||
456 | * This method is willingly generated in order to preserve the one-line inline validation within the setDiscount method |
||
457 | * @param array $values |
||
458 | * @return string A non-empty message if the values does not match the validation rules |
||
459 | */ |
||
460 | public static function validateDiscountForArrayConstraintsFromSetDiscount(array $values = array()) |
||
461 | { |
||
462 | $message = ''; |
||
463 | $invalidValues = []; |
||
464 | foreach ($values as $invoiceItemTypeDiscountItem) { |
||
465 | // validation for constraint: itemType |
||
466 | if (!$invoiceItemTypeDiscountItem instanceof \PayPal\StructType\DiscountType) { |
||
467 | $invalidValues[] = is_object($invoiceItemTypeDiscountItem) ? get_class($invoiceItemTypeDiscountItem) : sprintf('%s(%s)', gettype($invoiceItemTypeDiscountItem), var_export($invoiceItemTypeDiscountItem, true)); |
||
468 | } |
||
469 | } |
||
470 | if (!empty($invalidValues)) { |
||
471 | $message = sprintf('The Discount property can only contain items of type \PayPal\StructType\DiscountType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
472 | } |
||
473 | unset($invalidValues); |
||
474 | return $message; |
||
475 | } |
||
476 | /** |
||
477 | * Set Discount value |
||
478 | * @throws \InvalidArgumentException |
||
479 | * @param \PayPal\StructType\DiscountType[] $discount |
||
480 | * @return \PayPal\StructType\InvoiceItemType |
||
481 | */ |
||
482 | public function setDiscount(array $discount = array()) |
||
483 | { |
||
484 | // validation for constraint: array |
||
485 | if ('' !== ($discountArrayErrorMessage = self::validateDiscountForArrayConstraintsFromSetDiscount($discount))) { |
||
486 | throw new \InvalidArgumentException($discountArrayErrorMessage, __LINE__); |
||
487 | } |
||
488 | $this->Discount = $discount; |
||
489 | return $this; |
||
490 | } |
||
491 | /** |
||
492 | * Add item to Discount value |
||
493 | * @throws \InvalidArgumentException |
||
494 | * @param \PayPal\StructType\DiscountType $item |
||
495 | * @return \PayPal\StructType\InvoiceItemType |
||
496 | */ |
||
497 | public function addToDiscount(\PayPal\StructType\DiscountType $item) |
||
498 | { |
||
499 | // validation for constraint: itemType |
||
500 | if (!$item instanceof \PayPal\StructType\DiscountType) { |
||
501 | throw new \InvalidArgumentException(sprintf('The Discount property can only contain items of type \PayPal\StructType\DiscountType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
502 | } |
||
503 | $this->Discount[] = $item; |
||
504 | return $this; |
||
505 | } |
||
506 | /** |
||
507 | * Get Taxable value |
||
508 | * @return bool|null |
||
509 | */ |
||
510 | public function getTaxable() |
||
511 | { |
||
512 | return $this->Taxable; |
||
513 | } |
||
514 | /** |
||
515 | * Set Taxable value |
||
516 | * @param bool $taxable |
||
517 | * @return \PayPal\StructType\InvoiceItemType |
||
518 | */ |
||
519 | public function setTaxable($taxable = null) |
||
520 | { |
||
521 | // validation for constraint: boolean |
||
522 | if (!is_null($taxable) && !is_bool($taxable)) { |
||
523 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($taxable, true), gettype($taxable)), __LINE__); |
||
524 | } |
||
525 | $this->Taxable = $taxable; |
||
526 | return $this; |
||
527 | } |
||
528 | /** |
||
529 | * Get TaxRate value |
||
530 | * @return float|null |
||
531 | */ |
||
532 | public function getTaxRate() |
||
533 | { |
||
534 | return $this->TaxRate; |
||
535 | } |
||
536 | /** |
||
537 | * Set TaxRate value |
||
538 | * @param float $taxRate |
||
539 | * @return \PayPal\StructType\InvoiceItemType |
||
540 | */ |
||
541 | public function setTaxRate($taxRate = null) |
||
542 | { |
||
543 | // validation for constraint: float |
||
544 | if (!is_null($taxRate) && !(is_float($taxRate) || is_numeric($taxRate))) { |
||
545 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a float value, %s given', var_export($taxRate, true), gettype($taxRate)), __LINE__); |
||
546 | } |
||
547 | $this->TaxRate = $taxRate; |
||
548 | return $this; |
||
549 | } |
||
550 | /** |
||
551 | * Get AdditionalFees value |
||
552 | * @return \PayPal\StructType\AdditionalFeeType[]|null |
||
553 | */ |
||
554 | public function getAdditionalFees() |
||
555 | { |
||
556 | return $this->AdditionalFees; |
||
557 | } |
||
558 | /** |
||
559 | * This method is responsible for validating the values passed to the setAdditionalFees method |
||
560 | * This method is willingly generated in order to preserve the one-line inline validation within the setAdditionalFees method |
||
561 | * @param array $values |
||
562 | * @return string A non-empty message if the values does not match the validation rules |
||
563 | */ |
||
564 | public static function validateAdditionalFeesForArrayConstraintsFromSetAdditionalFees(array $values = array()) |
||
565 | { |
||
566 | $message = ''; |
||
567 | $invalidValues = []; |
||
568 | foreach ($values as $invoiceItemTypeAdditionalFeesItem) { |
||
569 | // validation for constraint: itemType |
||
570 | if (!$invoiceItemTypeAdditionalFeesItem instanceof \PayPal\StructType\AdditionalFeeType) { |
||
571 | $invalidValues[] = is_object($invoiceItemTypeAdditionalFeesItem) ? get_class($invoiceItemTypeAdditionalFeesItem) : sprintf('%s(%s)', gettype($invoiceItemTypeAdditionalFeesItem), var_export($invoiceItemTypeAdditionalFeesItem, true)); |
||
572 | } |
||
573 | } |
||
574 | if (!empty($invalidValues)) { |
||
575 | $message = sprintf('The AdditionalFees property can only contain items of type \PayPal\StructType\AdditionalFeeType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
576 | } |
||
577 | unset($invalidValues); |
||
578 | return $message; |
||
579 | } |
||
580 | /** |
||
581 | * Set AdditionalFees value |
||
582 | * @throws \InvalidArgumentException |
||
583 | * @param \PayPal\StructType\AdditionalFeeType[] $additionalFees |
||
584 | * @return \PayPal\StructType\InvoiceItemType |
||
585 | */ |
||
586 | public function setAdditionalFees(array $additionalFees = array()) |
||
587 | { |
||
588 | // validation for constraint: array |
||
589 | if ('' !== ($additionalFeesArrayErrorMessage = self::validateAdditionalFeesForArrayConstraintsFromSetAdditionalFees($additionalFees))) { |
||
590 | throw new \InvalidArgumentException($additionalFeesArrayErrorMessage, __LINE__); |
||
591 | } |
||
592 | $this->AdditionalFees = $additionalFees; |
||
593 | return $this; |
||
594 | } |
||
595 | /** |
||
596 | * Add item to AdditionalFees value |
||
597 | * @throws \InvalidArgumentException |
||
598 | * @param \PayPal\StructType\AdditionalFeeType $item |
||
599 | * @return \PayPal\StructType\InvoiceItemType |
||
600 | */ |
||
601 | public function addToAdditionalFees(\PayPal\StructType\AdditionalFeeType $item) |
||
602 | { |
||
603 | // validation for constraint: itemType |
||
604 | if (!$item instanceof \PayPal\StructType\AdditionalFeeType) { |
||
605 | throw new \InvalidArgumentException(sprintf('The AdditionalFees property can only contain items of type \PayPal\StructType\AdditionalFeeType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
606 | } |
||
607 | $this->AdditionalFees[] = $item; |
||
608 | return $this; |
||
609 | } |
||
610 | /** |
||
611 | * Get Reimbursable value |
||
612 | * @return bool|null |
||
613 | */ |
||
614 | public function getReimbursable() |
||
617 | } |
||
618 | /** |
||
619 | * Set Reimbursable value |
||
620 | * @param bool $reimbursable |
||
621 | * @return \PayPal\StructType\InvoiceItemType |
||
622 | */ |
||
623 | public function setReimbursable($reimbursable = null) |
||
631 | } |
||
632 | /** |
||
633 | * Get MPN value |
||
634 | * @return string|null |
||
635 | */ |
||
636 | public function getMPN() |
||
637 | { |
||
638 | return $this->MPN; |
||
639 | } |
||
640 | /** |
||
641 | * Set MPN value |
||
642 | * @param string $mPN |
||
643 | * @return \PayPal\StructType\InvoiceItemType |
||
644 | */ |
||
645 | public function setMPN($mPN = null) |
||
646 | { |
||
647 | // validation for constraint: string |
||
648 | if (!is_null($mPN) && !is_string($mPN)) { |
||
649 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($mPN, true), gettype($mPN)), __LINE__); |
||
650 | } |
||
651 | $this->MPN = $mPN; |
||
652 | return $this; |
||
653 | } |
||
654 | /** |
||
655 | * Get ISBN value |
||
656 | * @return string|null |
||
657 | */ |
||
658 | public function getISBN() |
||
661 | } |
||
662 | /** |
||
663 | * Set ISBN value |
||
664 | * @param string $iSBN |
||
665 | * @return \PayPal\StructType\InvoiceItemType |
||
666 | */ |
||
667 | public function setISBN($iSBN = null) |
||
668 | { |
||
669 | // validation for constraint: string |
||
670 | if (!is_null($iSBN) && !is_string($iSBN)) { |
||
671 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($iSBN, true), gettype($iSBN)), __LINE__); |
||
672 | } |
||
673 | $this->ISBN = $iSBN; |
||
674 | return $this; |
||
675 | } |
||
676 | /** |
||
677 | * Get PLU value |
||
678 | * @return string|null |
||
679 | */ |
||
680 | public function getPLU() |
||
681 | { |
||
682 | return $this->PLU; |
||
683 | } |
||
684 | /** |
||
685 | * Set PLU value |
||
686 | * @param string $pLU |
||
687 | * @return \PayPal\StructType\InvoiceItemType |
||
688 | */ |
||
689 | public function setPLU($pLU = null) |
||
697 | } |
||
698 | /** |
||
699 | * Get ModelNumber value |
||
700 | * @return string|null |
||
701 | */ |
||
702 | public function getModelNumber() |
||
703 | { |
||
704 | return $this->ModelNumber; |
||
705 | } |
||
706 | /** |
||
707 | * Set ModelNumber value |
||
708 | * @param string $modelNumber |
||
709 | * @return \PayPal\StructType\InvoiceItemType |
||
710 | */ |
||
711 | public function setModelNumber($modelNumber = null) |
||
719 | } |
||
720 | /** |
||
721 | * Get StyleNumber value |
||
722 | * @return string|null |
||
723 | */ |
||
724 | public function getStyleNumber() |
||
725 | { |
||
726 | return $this->StyleNumber; |
||
727 | } |
||
728 | /** |
||
729 | * Set StyleNumber value |
||
730 | * @param string $styleNumber |
||
731 | * @return \PayPal\StructType\InvoiceItemType |
||
732 | */ |
||
733 | public function setStyleNumber($styleNumber = null) |
||
741 | } |
||
742 | } |
||
743 |