Total Complexity | 67 |
Total Lines | 534 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like PaymentItemType 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 PaymentItemType, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class PaymentItemType extends AbstractStructBase |
||
15 | { |
||
16 | /** |
||
17 | * The EbayItemTxnId |
||
18 | * Meta information extracted from the WSDL |
||
19 | * - documentation: eBay Auction Transaction ID of the Item Optional Character length and limitations: 255 single-byte characters |
||
20 | * - minOccurs: 0 |
||
21 | * @var string |
||
22 | */ |
||
23 | public $EbayItemTxnId; |
||
24 | /** |
||
25 | * The Name |
||
26 | * Meta information extracted from the WSDL |
||
27 | * - documentation: Item name set by you or entered by the customer. Character length and limitations: 127 single-byte alphanumeric characters |
||
28 | * - minOccurs: 0 |
||
29 | * @var string |
||
30 | */ |
||
31 | public $Name; |
||
32 | /** |
||
33 | * The Number |
||
34 | * Meta information extracted from the WSDL |
||
35 | * - documentation: Item number set by you. Character length and limitations: 127 single-byte alphanumeric characters |
||
36 | * - minOccurs: 0 |
||
37 | * @var string |
||
38 | */ |
||
39 | public $Number; |
||
40 | /** |
||
41 | * The Quantity |
||
42 | * Meta information extracted from the WSDL |
||
43 | * - documentation: Quantity set by you or entered by the customer. Character length and limitations: no limit |
||
44 | * - minOccurs: 0 |
||
45 | * @var string |
||
46 | */ |
||
47 | public $Quantity; |
||
48 | /** |
||
49 | * The SalesTax |
||
50 | * Meta information extracted from the WSDL |
||
51 | * - documentation: Amount of tax charged on payment |
||
52 | * - minOccurs: 0 |
||
53 | * @var string |
||
54 | */ |
||
55 | public $SalesTax; |
||
56 | /** |
||
57 | * The ShippingAmount |
||
58 | * Meta information extracted from the WSDL |
||
59 | * - documentation: Amount of shipping charged on payment |
||
60 | * - minOccurs: 0 |
||
61 | * @var string |
||
62 | */ |
||
63 | public $ShippingAmount; |
||
64 | /** |
||
65 | * The HandlingAmount |
||
66 | * Meta information extracted from the WSDL |
||
67 | * - documentation: Amount of handling charged on payment |
||
68 | * - minOccurs: 0 |
||
69 | * @var string |
||
70 | */ |
||
71 | public $HandlingAmount; |
||
72 | /** |
||
73 | * The InvoiceItemDetails |
||
74 | * Meta information extracted from the WSDL |
||
75 | * - documentation: Invoice item details |
||
76 | * - minOccurs: 0 |
||
77 | * @var \PayPal\StructType\InvoiceItemType |
||
78 | */ |
||
79 | public $InvoiceItemDetails; |
||
80 | /** |
||
81 | * The CouponID |
||
82 | * Meta information extracted from the WSDL |
||
83 | * - documentation: Coupon ID Number |
||
84 | * - minOccurs: 0 |
||
85 | * @var string |
||
86 | */ |
||
87 | public $CouponID; |
||
88 | /** |
||
89 | * The CouponAmount |
||
90 | * Meta information extracted from the WSDL |
||
91 | * - documentation: Amount Value of The Coupon |
||
92 | * - minOccurs: 0 |
||
93 | * @var string |
||
94 | */ |
||
95 | public $CouponAmount; |
||
96 | /** |
||
97 | * The CouponAmountCurrency |
||
98 | * Meta information extracted from the WSDL |
||
99 | * - documentation: Currency of the Coupon Amount |
||
100 | * - minOccurs: 0 |
||
101 | * @var string |
||
102 | */ |
||
103 | public $CouponAmountCurrency; |
||
104 | /** |
||
105 | * The LoyaltyCardDiscountAmount |
||
106 | * Meta information extracted from the WSDL |
||
107 | * - documentation: Amount of Discount on this Loyalty Card |
||
108 | * - minOccurs: 0 |
||
109 | * @var string |
||
110 | */ |
||
111 | public $LoyaltyCardDiscountAmount; |
||
112 | /** |
||
113 | * The LoyaltyCardDiscountCurrency |
||
114 | * Meta information extracted from the WSDL |
||
115 | * - documentation: Currency of the Discount |
||
116 | * - minOccurs: 0 |
||
117 | * @var string |
||
118 | */ |
||
119 | public $LoyaltyCardDiscountCurrency; |
||
120 | /** |
||
121 | * The Amount |
||
122 | * Meta information extracted from the WSDL |
||
123 | * - documentation: Cost of item |
||
124 | * - minOccurs: 0 |
||
125 | * @var \PayPal\StructType\BasicAmountType |
||
126 | */ |
||
127 | public $Amount; |
||
128 | /** |
||
129 | * The Options |
||
130 | * Meta information extracted from the WSDL |
||
131 | * - documentation: Item options selected in PayPal shopping cart |
||
132 | * - maxOccurs: unbounded |
||
133 | * - minOccurs: 0 |
||
134 | * @var \PayPal\StructType\OptionType[] |
||
135 | */ |
||
136 | public $Options; |
||
137 | /** |
||
138 | * Constructor method for PaymentItemType |
||
139 | * @uses PaymentItemType::setEbayItemTxnId() |
||
140 | * @uses PaymentItemType::setName() |
||
141 | * @uses PaymentItemType::setNumber() |
||
142 | * @uses PaymentItemType::setQuantity() |
||
143 | * @uses PaymentItemType::setSalesTax() |
||
144 | * @uses PaymentItemType::setShippingAmount() |
||
145 | * @uses PaymentItemType::setHandlingAmount() |
||
146 | * @uses PaymentItemType::setInvoiceItemDetails() |
||
147 | * @uses PaymentItemType::setCouponID() |
||
148 | * @uses PaymentItemType::setCouponAmount() |
||
149 | * @uses PaymentItemType::setCouponAmountCurrency() |
||
150 | * @uses PaymentItemType::setLoyaltyCardDiscountAmount() |
||
151 | * @uses PaymentItemType::setLoyaltyCardDiscountCurrency() |
||
152 | * @uses PaymentItemType::setAmount() |
||
153 | * @uses PaymentItemType::setOptions() |
||
154 | * @param string $ebayItemTxnId |
||
155 | * @param string $name |
||
156 | * @param string $number |
||
157 | * @param string $quantity |
||
158 | * @param string $salesTax |
||
159 | * @param string $shippingAmount |
||
160 | * @param string $handlingAmount |
||
161 | * @param \PayPal\StructType\InvoiceItemType $invoiceItemDetails |
||
162 | * @param string $couponID |
||
163 | * @param string $couponAmount |
||
164 | * @param string $couponAmountCurrency |
||
165 | * @param string $loyaltyCardDiscountAmount |
||
166 | * @param string $loyaltyCardDiscountCurrency |
||
167 | * @param \PayPal\StructType\BasicAmountType $amount |
||
168 | * @param \PayPal\StructType\OptionType[] $options |
||
169 | */ |
||
170 | public function __construct($ebayItemTxnId = null, $name = null, $number = null, $quantity = null, $salesTax = null, $shippingAmount = null, $handlingAmount = null, \PayPal\StructType\InvoiceItemType $invoiceItemDetails = null, $couponID = null, $couponAmount = null, $couponAmountCurrency = null, $loyaltyCardDiscountAmount = null, $loyaltyCardDiscountCurrency = null, \PayPal\StructType\BasicAmountType $amount = null, array $options = array()) |
||
171 | { |
||
172 | $this |
||
173 | ->setEbayItemTxnId($ebayItemTxnId) |
||
174 | ->setName($name) |
||
175 | ->setNumber($number) |
||
176 | ->setQuantity($quantity) |
||
177 | ->setSalesTax($salesTax) |
||
178 | ->setShippingAmount($shippingAmount) |
||
179 | ->setHandlingAmount($handlingAmount) |
||
180 | ->setInvoiceItemDetails($invoiceItemDetails) |
||
181 | ->setCouponID($couponID) |
||
182 | ->setCouponAmount($couponAmount) |
||
183 | ->setCouponAmountCurrency($couponAmountCurrency) |
||
184 | ->setLoyaltyCardDiscountAmount($loyaltyCardDiscountAmount) |
||
185 | ->setLoyaltyCardDiscountCurrency($loyaltyCardDiscountCurrency) |
||
186 | ->setAmount($amount) |
||
187 | ->setOptions($options); |
||
188 | } |
||
189 | /** |
||
190 | * Get EbayItemTxnId value |
||
191 | * @return string|null |
||
192 | */ |
||
193 | public function getEbayItemTxnId() |
||
194 | { |
||
195 | return $this->EbayItemTxnId; |
||
196 | } |
||
197 | /** |
||
198 | * Set EbayItemTxnId value |
||
199 | * @param string $ebayItemTxnId |
||
200 | * @return \PayPal\StructType\PaymentItemType |
||
201 | */ |
||
202 | public function setEbayItemTxnId($ebayItemTxnId = null) |
||
203 | { |
||
204 | // validation for constraint: string |
||
205 | if (!is_null($ebayItemTxnId) && !is_string($ebayItemTxnId)) { |
||
|
|||
206 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($ebayItemTxnId, true), gettype($ebayItemTxnId)), __LINE__); |
||
207 | } |
||
208 | $this->EbayItemTxnId = $ebayItemTxnId; |
||
209 | return $this; |
||
210 | } |
||
211 | /** |
||
212 | * Get Name value |
||
213 | * @return string|null |
||
214 | */ |
||
215 | public function getName() |
||
216 | { |
||
217 | return $this->Name; |
||
218 | } |
||
219 | /** |
||
220 | * Set Name value |
||
221 | * @param string $name |
||
222 | * @return \PayPal\StructType\PaymentItemType |
||
223 | */ |
||
224 | public function setName($name = null) |
||
225 | { |
||
226 | // validation for constraint: string |
||
227 | if (!is_null($name) && !is_string($name)) { |
||
228 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($name, true), gettype($name)), __LINE__); |
||
229 | } |
||
230 | $this->Name = $name; |
||
231 | return $this; |
||
232 | } |
||
233 | /** |
||
234 | * Get Number value |
||
235 | * @return string|null |
||
236 | */ |
||
237 | public function getNumber() |
||
238 | { |
||
239 | return $this->Number; |
||
240 | } |
||
241 | /** |
||
242 | * Set Number value |
||
243 | * @param string $number |
||
244 | * @return \PayPal\StructType\PaymentItemType |
||
245 | */ |
||
246 | public function setNumber($number = null) |
||
247 | { |
||
248 | // validation for constraint: string |
||
249 | if (!is_null($number) && !is_string($number)) { |
||
250 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($number, true), gettype($number)), __LINE__); |
||
251 | } |
||
252 | $this->Number = $number; |
||
253 | return $this; |
||
254 | } |
||
255 | /** |
||
256 | * Get Quantity value |
||
257 | * @return string|null |
||
258 | */ |
||
259 | public function getQuantity() |
||
260 | { |
||
261 | return $this->Quantity; |
||
262 | } |
||
263 | /** |
||
264 | * Set Quantity value |
||
265 | * @param string $quantity |
||
266 | * @return \PayPal\StructType\PaymentItemType |
||
267 | */ |
||
268 | public function setQuantity($quantity = null) |
||
269 | { |
||
270 | // validation for constraint: string |
||
271 | if (!is_null($quantity) && !is_string($quantity)) { |
||
272 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($quantity, true), gettype($quantity)), __LINE__); |
||
273 | } |
||
274 | $this->Quantity = $quantity; |
||
275 | return $this; |
||
276 | } |
||
277 | /** |
||
278 | * Get SalesTax value |
||
279 | * @return string|null |
||
280 | */ |
||
281 | public function getSalesTax() |
||
282 | { |
||
283 | return $this->SalesTax; |
||
284 | } |
||
285 | /** |
||
286 | * Set SalesTax value |
||
287 | * @param string $salesTax |
||
288 | * @return \PayPal\StructType\PaymentItemType |
||
289 | */ |
||
290 | public function setSalesTax($salesTax = null) |
||
298 | } |
||
299 | /** |
||
300 | * Get ShippingAmount value |
||
301 | * @return string|null |
||
302 | */ |
||
303 | public function getShippingAmount() |
||
304 | { |
||
305 | return $this->ShippingAmount; |
||
306 | } |
||
307 | /** |
||
308 | * Set ShippingAmount value |
||
309 | * @param string $shippingAmount |
||
310 | * @return \PayPal\StructType\PaymentItemType |
||
311 | */ |
||
312 | public function setShippingAmount($shippingAmount = null) |
||
313 | { |
||
314 | // validation for constraint: string |
||
315 | if (!is_null($shippingAmount) && !is_string($shippingAmount)) { |
||
316 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($shippingAmount, true), gettype($shippingAmount)), __LINE__); |
||
317 | } |
||
318 | $this->ShippingAmount = $shippingAmount; |
||
319 | return $this; |
||
320 | } |
||
321 | /** |
||
322 | * Get HandlingAmount value |
||
323 | * @return string|null |
||
324 | */ |
||
325 | public function getHandlingAmount() |
||
326 | { |
||
327 | return $this->HandlingAmount; |
||
328 | } |
||
329 | /** |
||
330 | * Set HandlingAmount value |
||
331 | * @param string $handlingAmount |
||
332 | * @return \PayPal\StructType\PaymentItemType |
||
333 | */ |
||
334 | public function setHandlingAmount($handlingAmount = null) |
||
335 | { |
||
336 | // validation for constraint: string |
||
337 | if (!is_null($handlingAmount) && !is_string($handlingAmount)) { |
||
338 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($handlingAmount, true), gettype($handlingAmount)), __LINE__); |
||
339 | } |
||
340 | $this->HandlingAmount = $handlingAmount; |
||
341 | return $this; |
||
342 | } |
||
343 | /** |
||
344 | * Get InvoiceItemDetails value |
||
345 | * @return \PayPal\StructType\InvoiceItemType|null |
||
346 | */ |
||
347 | public function getInvoiceItemDetails() |
||
348 | { |
||
349 | return $this->InvoiceItemDetails; |
||
350 | } |
||
351 | /** |
||
352 | * Set InvoiceItemDetails value |
||
353 | * @param \PayPal\StructType\InvoiceItemType $invoiceItemDetails |
||
354 | * @return \PayPal\StructType\PaymentItemType |
||
355 | */ |
||
356 | public function setInvoiceItemDetails(\PayPal\StructType\InvoiceItemType $invoiceItemDetails = null) |
||
357 | { |
||
358 | $this->InvoiceItemDetails = $invoiceItemDetails; |
||
359 | return $this; |
||
360 | } |
||
361 | /** |
||
362 | * Get CouponID value |
||
363 | * @return string|null |
||
364 | */ |
||
365 | public function getCouponID() |
||
366 | { |
||
367 | return $this->CouponID; |
||
368 | } |
||
369 | /** |
||
370 | * Set CouponID value |
||
371 | * @param string $couponID |
||
372 | * @return \PayPal\StructType\PaymentItemType |
||
373 | */ |
||
374 | public function setCouponID($couponID = null) |
||
375 | { |
||
376 | // validation for constraint: string |
||
377 | if (!is_null($couponID) && !is_string($couponID)) { |
||
378 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($couponID, true), gettype($couponID)), __LINE__); |
||
379 | } |
||
380 | $this->CouponID = $couponID; |
||
381 | return $this; |
||
382 | } |
||
383 | /** |
||
384 | * Get CouponAmount value |
||
385 | * @return string|null |
||
386 | */ |
||
387 | public function getCouponAmount() |
||
388 | { |
||
389 | return $this->CouponAmount; |
||
390 | } |
||
391 | /** |
||
392 | * Set CouponAmount value |
||
393 | * @param string $couponAmount |
||
394 | * @return \PayPal\StructType\PaymentItemType |
||
395 | */ |
||
396 | public function setCouponAmount($couponAmount = null) |
||
397 | { |
||
398 | // validation for constraint: string |
||
399 | if (!is_null($couponAmount) && !is_string($couponAmount)) { |
||
400 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($couponAmount, true), gettype($couponAmount)), __LINE__); |
||
401 | } |
||
402 | $this->CouponAmount = $couponAmount; |
||
403 | return $this; |
||
404 | } |
||
405 | /** |
||
406 | * Get CouponAmountCurrency value |
||
407 | * @return string|null |
||
408 | */ |
||
409 | public function getCouponAmountCurrency() |
||
410 | { |
||
411 | return $this->CouponAmountCurrency; |
||
412 | } |
||
413 | /** |
||
414 | * Set CouponAmountCurrency value |
||
415 | * @param string $couponAmountCurrency |
||
416 | * @return \PayPal\StructType\PaymentItemType |
||
417 | */ |
||
418 | public function setCouponAmountCurrency($couponAmountCurrency = null) |
||
419 | { |
||
420 | // validation for constraint: string |
||
421 | if (!is_null($couponAmountCurrency) && !is_string($couponAmountCurrency)) { |
||
422 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($couponAmountCurrency, true), gettype($couponAmountCurrency)), __LINE__); |
||
423 | } |
||
424 | $this->CouponAmountCurrency = $couponAmountCurrency; |
||
425 | return $this; |
||
426 | } |
||
427 | /** |
||
428 | * Get LoyaltyCardDiscountAmount value |
||
429 | * @return string|null |
||
430 | */ |
||
431 | public function getLoyaltyCardDiscountAmount() |
||
434 | } |
||
435 | /** |
||
436 | * Set LoyaltyCardDiscountAmount value |
||
437 | * @param string $loyaltyCardDiscountAmount |
||
438 | * @return \PayPal\StructType\PaymentItemType |
||
439 | */ |
||
440 | public function setLoyaltyCardDiscountAmount($loyaltyCardDiscountAmount = null) |
||
441 | { |
||
442 | // validation for constraint: string |
||
443 | if (!is_null($loyaltyCardDiscountAmount) && !is_string($loyaltyCardDiscountAmount)) { |
||
444 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($loyaltyCardDiscountAmount, true), gettype($loyaltyCardDiscountAmount)), __LINE__); |
||
445 | } |
||
446 | $this->LoyaltyCardDiscountAmount = $loyaltyCardDiscountAmount; |
||
447 | return $this; |
||
448 | } |
||
449 | /** |
||
450 | * Get LoyaltyCardDiscountCurrency value |
||
451 | * @return string|null |
||
452 | */ |
||
453 | public function getLoyaltyCardDiscountCurrency() |
||
454 | { |
||
455 | return $this->LoyaltyCardDiscountCurrency; |
||
456 | } |
||
457 | /** |
||
458 | * Set LoyaltyCardDiscountCurrency value |
||
459 | * @param string $loyaltyCardDiscountCurrency |
||
460 | * @return \PayPal\StructType\PaymentItemType |
||
461 | */ |
||
462 | public function setLoyaltyCardDiscountCurrency($loyaltyCardDiscountCurrency = null) |
||
463 | { |
||
464 | // validation for constraint: string |
||
465 | if (!is_null($loyaltyCardDiscountCurrency) && !is_string($loyaltyCardDiscountCurrency)) { |
||
466 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($loyaltyCardDiscountCurrency, true), gettype($loyaltyCardDiscountCurrency)), __LINE__); |
||
467 | } |
||
468 | $this->LoyaltyCardDiscountCurrency = $loyaltyCardDiscountCurrency; |
||
469 | return $this; |
||
470 | } |
||
471 | /** |
||
472 | * Get Amount value |
||
473 | * @return \PayPal\StructType\BasicAmountType|null |
||
474 | */ |
||
475 | public function getAmount() |
||
478 | } |
||
479 | /** |
||
480 | * Set Amount value |
||
481 | * @param \PayPal\StructType\BasicAmountType $amount |
||
482 | * @return \PayPal\StructType\PaymentItemType |
||
483 | */ |
||
484 | public function setAmount(\PayPal\StructType\BasicAmountType $amount = null) |
||
485 | { |
||
486 | $this->Amount = $amount; |
||
487 | return $this; |
||
488 | } |
||
489 | /** |
||
490 | * Get Options value |
||
491 | * @return \PayPal\StructType\OptionType[]|null |
||
492 | */ |
||
493 | public function getOptions() |
||
494 | { |
||
495 | return $this->Options; |
||
496 | } |
||
497 | /** |
||
498 | * This method is responsible for validating the values passed to the setOptions method |
||
499 | * This method is willingly generated in order to preserve the one-line inline validation within the setOptions method |
||
500 | * @param array $values |
||
501 | * @return string A non-empty message if the values does not match the validation rules |
||
502 | */ |
||
503 | public static function validateOptionsForArrayConstraintsFromSetOptions(array $values = array()) |
||
518 | } |
||
519 | /** |
||
520 | * Set Options value |
||
521 | * @throws \InvalidArgumentException |
||
522 | * @param \PayPal\StructType\OptionType[] $options |
||
523 | * @return \PayPal\StructType\PaymentItemType |
||
524 | */ |
||
525 | public function setOptions(array $options = array()) |
||
526 | { |
||
527 | // validation for constraint: array |
||
528 | if ('' !== ($optionsArrayErrorMessage = self::validateOptionsForArrayConstraintsFromSetOptions($options))) { |
||
529 | throw new \InvalidArgumentException($optionsArrayErrorMessage, __LINE__); |
||
530 | } |
||
531 | $this->Options = $options; |
||
532 | return $this; |
||
533 | } |
||
534 | /** |
||
535 | * Add item to Options value |
||
536 | * @throws \InvalidArgumentException |
||
537 | * @param \PayPal\StructType\OptionType $item |
||
538 | * @return \PayPal\StructType\PaymentItemType |
||
539 | */ |
||
540 | public function addToOptions(\PayPal\StructType\OptionType $item) |
||
548 | } |
||
549 | } |
||
550 |