Total Complexity | 84 |
Total Lines | 540 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like CategoryType 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 CategoryType, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class CategoryType extends AbstractStructBase |
||
15 | { |
||
16 | /** |
||
17 | * The AutoPayEnabled |
||
18 | * Meta information extracted from the WSDL |
||
19 | * - minOccurs: 0 |
||
20 | * @var bool |
||
21 | */ |
||
22 | public $AutoPayEnabled; |
||
23 | /** |
||
24 | * The B2BVATEnabled |
||
25 | * Meta information extracted from the WSDL |
||
26 | * - minOccurs: 0 |
||
27 | * @var bool |
||
28 | */ |
||
29 | public $B2BVATEnabled; |
||
30 | /** |
||
31 | * The CatalogEnabled |
||
32 | * Meta information extracted from the WSDL |
||
33 | * - minOccurs: 0 |
||
34 | * @var bool |
||
35 | */ |
||
36 | public $CatalogEnabled; |
||
37 | /** |
||
38 | * The CategoryID |
||
39 | * @var string |
||
40 | */ |
||
41 | public $CategoryID; |
||
42 | /** |
||
43 | * The CategoryLevel |
||
44 | * Meta information extracted from the WSDL |
||
45 | * - minOccurs: 0 |
||
46 | * @var int |
||
47 | */ |
||
48 | public $CategoryLevel; |
||
49 | /** |
||
50 | * The CategoryName |
||
51 | * Meta information extracted from the WSDL |
||
52 | * - minOccurs: 0 |
||
53 | * @var string |
||
54 | */ |
||
55 | public $CategoryName; |
||
56 | /** |
||
57 | * The CategoryParentID |
||
58 | * Meta information extracted from the WSDL |
||
59 | * - maxOccurs: unbounded |
||
60 | * - minOccurs: 0 |
||
61 | * @var string[] |
||
62 | */ |
||
63 | public $CategoryParentID; |
||
64 | /** |
||
65 | * The CategoryParentName |
||
66 | * Meta information extracted from the WSDL |
||
67 | * - maxOccurs: unbounded |
||
68 | * - minOccurs: 0 |
||
69 | * @var string[] |
||
70 | */ |
||
71 | public $CategoryParentName; |
||
72 | /** |
||
73 | * The CSIDList |
||
74 | * Meta information extracted from the WSDL |
||
75 | * - documentation: CSIDList is not present if Attributes enabled. |
||
76 | * - maxOccurs: unbounded |
||
77 | * - minOccurs: 0 |
||
78 | * @var string[] |
||
79 | */ |
||
80 | public $CSIDList; |
||
81 | /** |
||
82 | * The Expired |
||
83 | * Meta information extracted from the WSDL |
||
84 | * - minOccurs: 0 |
||
85 | * @var bool |
||
86 | */ |
||
87 | public $Expired; |
||
88 | /** |
||
89 | * The IntlAutosFixedCat |
||
90 | * Meta information extracted from the WSDL |
||
91 | * - minOccurs: 0 |
||
92 | * @var bool |
||
93 | */ |
||
94 | public $IntlAutosFixedCat; |
||
95 | /** |
||
96 | * The LeafCategory |
||
97 | * Meta information extracted from the WSDL |
||
98 | * - minOccurs: 0 |
||
99 | * @var bool |
||
100 | */ |
||
101 | public $LeafCategory; |
||
102 | /** |
||
103 | * The Virtual |
||
104 | * Meta information extracted from the WSDL |
||
105 | * - minOccurs: 0 |
||
106 | * @var bool |
||
107 | */ |
||
108 | public $Virtual; |
||
109 | /** |
||
110 | * Constructor method for CategoryType |
||
111 | * @uses CategoryType::setAutoPayEnabled() |
||
112 | * @uses CategoryType::setB2BVATEnabled() |
||
113 | * @uses CategoryType::setCatalogEnabled() |
||
114 | * @uses CategoryType::setCategoryID() |
||
115 | * @uses CategoryType::setCategoryLevel() |
||
116 | * @uses CategoryType::setCategoryName() |
||
117 | * @uses CategoryType::setCategoryParentID() |
||
118 | * @uses CategoryType::setCategoryParentName() |
||
119 | * @uses CategoryType::setCSIDList() |
||
120 | * @uses CategoryType::setExpired() |
||
121 | * @uses CategoryType::setIntlAutosFixedCat() |
||
122 | * @uses CategoryType::setLeafCategory() |
||
123 | * @uses CategoryType::setVirtual() |
||
124 | * @param bool $autoPayEnabled |
||
125 | * @param bool $b2BVATEnabled |
||
126 | * @param bool $catalogEnabled |
||
127 | * @param string $categoryID |
||
128 | * @param int $categoryLevel |
||
129 | * @param string $categoryName |
||
130 | * @param string[] $categoryParentID |
||
131 | * @param string[] $categoryParentName |
||
132 | * @param string[] $cSIDList |
||
133 | * @param bool $expired |
||
134 | * @param bool $intlAutosFixedCat |
||
135 | * @param bool $leafCategory |
||
136 | * @param bool $virtual |
||
137 | */ |
||
138 | public function __construct($autoPayEnabled = null, $b2BVATEnabled = null, $catalogEnabled = null, $categoryID = null, $categoryLevel = null, $categoryName = null, array $categoryParentID = array(), array $categoryParentName = array(), array $cSIDList = array(), $expired = null, $intlAutosFixedCat = null, $leafCategory = null, $virtual = null) |
||
139 | { |
||
140 | $this |
||
141 | ->setAutoPayEnabled($autoPayEnabled) |
||
142 | ->setB2BVATEnabled($b2BVATEnabled) |
||
143 | ->setCatalogEnabled($catalogEnabled) |
||
144 | ->setCategoryID($categoryID) |
||
145 | ->setCategoryLevel($categoryLevel) |
||
146 | ->setCategoryName($categoryName) |
||
147 | ->setCategoryParentID($categoryParentID) |
||
148 | ->setCategoryParentName($categoryParentName) |
||
149 | ->setCSIDList($cSIDList) |
||
150 | ->setExpired($expired) |
||
151 | ->setIntlAutosFixedCat($intlAutosFixedCat) |
||
152 | ->setLeafCategory($leafCategory) |
||
153 | ->setVirtual($virtual); |
||
154 | } |
||
155 | /** |
||
156 | * Get AutoPayEnabled value |
||
157 | * @return bool|null |
||
158 | */ |
||
159 | public function getAutoPayEnabled() |
||
160 | { |
||
161 | return $this->AutoPayEnabled; |
||
162 | } |
||
163 | /** |
||
164 | * Set AutoPayEnabled value |
||
165 | * @param bool $autoPayEnabled |
||
166 | * @return \PayPal\StructType\CategoryType |
||
167 | */ |
||
168 | public function setAutoPayEnabled($autoPayEnabled = null) |
||
169 | { |
||
170 | // validation for constraint: boolean |
||
171 | if (!is_null($autoPayEnabled) && !is_bool($autoPayEnabled)) { |
||
|
|||
172 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($autoPayEnabled, true), gettype($autoPayEnabled)), __LINE__); |
||
173 | } |
||
174 | $this->AutoPayEnabled = $autoPayEnabled; |
||
175 | return $this; |
||
176 | } |
||
177 | /** |
||
178 | * Get B2BVATEnabled value |
||
179 | * @return bool|null |
||
180 | */ |
||
181 | public function getB2BVATEnabled() |
||
182 | { |
||
183 | return $this->B2BVATEnabled; |
||
184 | } |
||
185 | /** |
||
186 | * Set B2BVATEnabled value |
||
187 | * @param bool $b2BVATEnabled |
||
188 | * @return \PayPal\StructType\CategoryType |
||
189 | */ |
||
190 | public function setB2BVATEnabled($b2BVATEnabled = null) |
||
191 | { |
||
192 | // validation for constraint: boolean |
||
193 | if (!is_null($b2BVATEnabled) && !is_bool($b2BVATEnabled)) { |
||
194 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($b2BVATEnabled, true), gettype($b2BVATEnabled)), __LINE__); |
||
195 | } |
||
196 | $this->B2BVATEnabled = $b2BVATEnabled; |
||
197 | return $this; |
||
198 | } |
||
199 | /** |
||
200 | * Get CatalogEnabled value |
||
201 | * @return bool|null |
||
202 | */ |
||
203 | public function getCatalogEnabled() |
||
204 | { |
||
205 | return $this->CatalogEnabled; |
||
206 | } |
||
207 | /** |
||
208 | * Set CatalogEnabled value |
||
209 | * @param bool $catalogEnabled |
||
210 | * @return \PayPal\StructType\CategoryType |
||
211 | */ |
||
212 | public function setCatalogEnabled($catalogEnabled = null) |
||
213 | { |
||
214 | // validation for constraint: boolean |
||
215 | if (!is_null($catalogEnabled) && !is_bool($catalogEnabled)) { |
||
216 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($catalogEnabled, true), gettype($catalogEnabled)), __LINE__); |
||
217 | } |
||
218 | $this->CatalogEnabled = $catalogEnabled; |
||
219 | return $this; |
||
220 | } |
||
221 | /** |
||
222 | * Get CategoryID value |
||
223 | * @return string|null |
||
224 | */ |
||
225 | public function getCategoryID() |
||
226 | { |
||
227 | return $this->CategoryID; |
||
228 | } |
||
229 | /** |
||
230 | * Set CategoryID value |
||
231 | * @param string $categoryID |
||
232 | * @return \PayPal\StructType\CategoryType |
||
233 | */ |
||
234 | public function setCategoryID($categoryID = null) |
||
235 | { |
||
236 | // validation for constraint: string |
||
237 | if (!is_null($categoryID) && !is_string($categoryID)) { |
||
238 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($categoryID, true), gettype($categoryID)), __LINE__); |
||
239 | } |
||
240 | $this->CategoryID = $categoryID; |
||
241 | return $this; |
||
242 | } |
||
243 | /** |
||
244 | * Get CategoryLevel value |
||
245 | * @return int|null |
||
246 | */ |
||
247 | public function getCategoryLevel() |
||
248 | { |
||
249 | return $this->CategoryLevel; |
||
250 | } |
||
251 | /** |
||
252 | * Set CategoryLevel value |
||
253 | * @param int $categoryLevel |
||
254 | * @return \PayPal\StructType\CategoryType |
||
255 | */ |
||
256 | public function setCategoryLevel($categoryLevel = null) |
||
257 | { |
||
258 | // validation for constraint: int |
||
259 | if (!is_null($categoryLevel) && !(is_int($categoryLevel) || ctype_digit($categoryLevel))) { |
||
260 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide an integer value, %s given', var_export($categoryLevel, true), gettype($categoryLevel)), __LINE__); |
||
261 | } |
||
262 | $this->CategoryLevel = $categoryLevel; |
||
263 | return $this; |
||
264 | } |
||
265 | /** |
||
266 | * Get CategoryName value |
||
267 | * @return string|null |
||
268 | */ |
||
269 | public function getCategoryName() |
||
270 | { |
||
271 | return $this->CategoryName; |
||
272 | } |
||
273 | /** |
||
274 | * Set CategoryName value |
||
275 | * @param string $categoryName |
||
276 | * @return \PayPal\StructType\CategoryType |
||
277 | */ |
||
278 | public function setCategoryName($categoryName = null) |
||
279 | { |
||
280 | // validation for constraint: string |
||
281 | if (!is_null($categoryName) && !is_string($categoryName)) { |
||
282 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($categoryName, true), gettype($categoryName)), __LINE__); |
||
283 | } |
||
284 | $this->CategoryName = $categoryName; |
||
285 | return $this; |
||
286 | } |
||
287 | /** |
||
288 | * Get CategoryParentID value |
||
289 | * @return string[]|null |
||
290 | */ |
||
291 | public function getCategoryParentID() |
||
292 | { |
||
293 | return $this->CategoryParentID; |
||
294 | } |
||
295 | /** |
||
296 | * This method is responsible for validating the values passed to the setCategoryParentID method |
||
297 | * This method is willingly generated in order to preserve the one-line inline validation within the setCategoryParentID method |
||
298 | * @param array $values |
||
299 | * @return string A non-empty message if the values does not match the validation rules |
||
300 | */ |
||
301 | public static function validateCategoryParentIDForArrayConstraintsFromSetCategoryParentID(array $values = array()) |
||
302 | { |
||
303 | $message = ''; |
||
304 | $invalidValues = []; |
||
305 | foreach ($values as $categoryTypeCategoryParentIDItem) { |
||
306 | // validation for constraint: itemType |
||
307 | if (!is_string($categoryTypeCategoryParentIDItem)) { |
||
308 | $invalidValues[] = is_object($categoryTypeCategoryParentIDItem) ? get_class($categoryTypeCategoryParentIDItem) : sprintf('%s(%s)', gettype($categoryTypeCategoryParentIDItem), var_export($categoryTypeCategoryParentIDItem, true)); |
||
309 | } |
||
310 | } |
||
311 | if (!empty($invalidValues)) { |
||
312 | $message = sprintf('The CategoryParentID property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
313 | } |
||
314 | unset($invalidValues); |
||
315 | return $message; |
||
316 | } |
||
317 | /** |
||
318 | * Set CategoryParentID value |
||
319 | * @throws \InvalidArgumentException |
||
320 | * @param string[] $categoryParentID |
||
321 | * @return \PayPal\StructType\CategoryType |
||
322 | */ |
||
323 | public function setCategoryParentID(array $categoryParentID = array()) |
||
324 | { |
||
325 | // validation for constraint: array |
||
326 | if ('' !== ($categoryParentIDArrayErrorMessage = self::validateCategoryParentIDForArrayConstraintsFromSetCategoryParentID($categoryParentID))) { |
||
327 | throw new \InvalidArgumentException($categoryParentIDArrayErrorMessage, __LINE__); |
||
328 | } |
||
329 | $this->CategoryParentID = $categoryParentID; |
||
330 | return $this; |
||
331 | } |
||
332 | /** |
||
333 | * Add item to CategoryParentID value |
||
334 | * @throws \InvalidArgumentException |
||
335 | * @param string $item |
||
336 | * @return \PayPal\StructType\CategoryType |
||
337 | */ |
||
338 | public function addToCategoryParentID($item) |
||
339 | { |
||
340 | // validation for constraint: itemType |
||
341 | if (!is_string($item)) { |
||
342 | throw new \InvalidArgumentException(sprintf('The CategoryParentID property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
343 | } |
||
344 | $this->CategoryParentID[] = $item; |
||
345 | return $this; |
||
346 | } |
||
347 | /** |
||
348 | * Get CategoryParentName value |
||
349 | * @return string[]|null |
||
350 | */ |
||
351 | public function getCategoryParentName() |
||
352 | { |
||
353 | return $this->CategoryParentName; |
||
354 | } |
||
355 | /** |
||
356 | * This method is responsible for validating the values passed to the setCategoryParentName method |
||
357 | * This method is willingly generated in order to preserve the one-line inline validation within the setCategoryParentName method |
||
358 | * @param array $values |
||
359 | * @return string A non-empty message if the values does not match the validation rules |
||
360 | */ |
||
361 | public static function validateCategoryParentNameForArrayConstraintsFromSetCategoryParentName(array $values = array()) |
||
376 | } |
||
377 | /** |
||
378 | * Set CategoryParentName value |
||
379 | * @throws \InvalidArgumentException |
||
380 | * @param string[] $categoryParentName |
||
381 | * @return \PayPal\StructType\CategoryType |
||
382 | */ |
||
383 | public function setCategoryParentName(array $categoryParentName = array()) |
||
384 | { |
||
385 | // validation for constraint: array |
||
386 | if ('' !== ($categoryParentNameArrayErrorMessage = self::validateCategoryParentNameForArrayConstraintsFromSetCategoryParentName($categoryParentName))) { |
||
387 | throw new \InvalidArgumentException($categoryParentNameArrayErrorMessage, __LINE__); |
||
388 | } |
||
389 | $this->CategoryParentName = $categoryParentName; |
||
390 | return $this; |
||
391 | } |
||
392 | /** |
||
393 | * Add item to CategoryParentName value |
||
394 | * @throws \InvalidArgumentException |
||
395 | * @param string $item |
||
396 | * @return \PayPal\StructType\CategoryType |
||
397 | */ |
||
398 | public function addToCategoryParentName($item) |
||
399 | { |
||
400 | // validation for constraint: itemType |
||
401 | if (!is_string($item)) { |
||
402 | throw new \InvalidArgumentException(sprintf('The CategoryParentName property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
403 | } |
||
404 | $this->CategoryParentName[] = $item; |
||
405 | return $this; |
||
406 | } |
||
407 | /** |
||
408 | * Get CSIDList value |
||
409 | * @return string[]|null |
||
410 | */ |
||
411 | public function getCSIDList() |
||
412 | { |
||
413 | return $this->CSIDList; |
||
414 | } |
||
415 | /** |
||
416 | * This method is responsible for validating the values passed to the setCSIDList method |
||
417 | * This method is willingly generated in order to preserve the one-line inline validation within the setCSIDList method |
||
418 | * @param array $values |
||
419 | * @return string A non-empty message if the values does not match the validation rules |
||
420 | */ |
||
421 | public static function validateCSIDListForArrayConstraintsFromSetCSIDList(array $values = array()) |
||
422 | { |
||
423 | $message = ''; |
||
424 | $invalidValues = []; |
||
425 | foreach ($values as $categoryTypeCSIDListItem) { |
||
426 | // validation for constraint: itemType |
||
427 | if (!is_string($categoryTypeCSIDListItem)) { |
||
428 | $invalidValues[] = is_object($categoryTypeCSIDListItem) ? get_class($categoryTypeCSIDListItem) : sprintf('%s(%s)', gettype($categoryTypeCSIDListItem), var_export($categoryTypeCSIDListItem, true)); |
||
429 | } |
||
430 | } |
||
431 | if (!empty($invalidValues)) { |
||
432 | $message = sprintf('The CSIDList property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
433 | } |
||
434 | unset($invalidValues); |
||
435 | return $message; |
||
436 | } |
||
437 | /** |
||
438 | * Set CSIDList value |
||
439 | * @throws \InvalidArgumentException |
||
440 | * @param string[] $cSIDList |
||
441 | * @return \PayPal\StructType\CategoryType |
||
442 | */ |
||
443 | public function setCSIDList(array $cSIDList = array()) |
||
444 | { |
||
445 | // validation for constraint: array |
||
446 | if ('' !== ($cSIDListArrayErrorMessage = self::validateCSIDListForArrayConstraintsFromSetCSIDList($cSIDList))) { |
||
447 | throw new \InvalidArgumentException($cSIDListArrayErrorMessage, __LINE__); |
||
448 | } |
||
449 | $this->CSIDList = $cSIDList; |
||
450 | return $this; |
||
451 | } |
||
452 | /** |
||
453 | * Add item to CSIDList value |
||
454 | * @throws \InvalidArgumentException |
||
455 | * @param string $item |
||
456 | * @return \PayPal\StructType\CategoryType |
||
457 | */ |
||
458 | public function addToCSIDList($item) |
||
459 | { |
||
460 | // validation for constraint: itemType |
||
461 | if (!is_string($item)) { |
||
462 | throw new \InvalidArgumentException(sprintf('The CSIDList property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
463 | } |
||
464 | $this->CSIDList[] = $item; |
||
465 | return $this; |
||
466 | } |
||
467 | /** |
||
468 | * Get Expired value |
||
469 | * @return bool|null |
||
470 | */ |
||
471 | public function getExpired() |
||
472 | { |
||
473 | return $this->Expired; |
||
474 | } |
||
475 | /** |
||
476 | * Set Expired value |
||
477 | * @param bool $expired |
||
478 | * @return \PayPal\StructType\CategoryType |
||
479 | */ |
||
480 | public function setExpired($expired = null) |
||
481 | { |
||
482 | // validation for constraint: boolean |
||
483 | if (!is_null($expired) && !is_bool($expired)) { |
||
484 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($expired, true), gettype($expired)), __LINE__); |
||
485 | } |
||
486 | $this->Expired = $expired; |
||
487 | return $this; |
||
488 | } |
||
489 | /** |
||
490 | * Get IntlAutosFixedCat value |
||
491 | * @return bool|null |
||
492 | */ |
||
493 | public function getIntlAutosFixedCat() |
||
494 | { |
||
495 | return $this->IntlAutosFixedCat; |
||
496 | } |
||
497 | /** |
||
498 | * Set IntlAutosFixedCat value |
||
499 | * @param bool $intlAutosFixedCat |
||
500 | * @return \PayPal\StructType\CategoryType |
||
501 | */ |
||
502 | public function setIntlAutosFixedCat($intlAutosFixedCat = null) |
||
503 | { |
||
504 | // validation for constraint: boolean |
||
505 | if (!is_null($intlAutosFixedCat) && !is_bool($intlAutosFixedCat)) { |
||
506 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($intlAutosFixedCat, true), gettype($intlAutosFixedCat)), __LINE__); |
||
507 | } |
||
508 | $this->IntlAutosFixedCat = $intlAutosFixedCat; |
||
509 | return $this; |
||
510 | } |
||
511 | /** |
||
512 | * Get LeafCategory value |
||
513 | * @return bool|null |
||
514 | */ |
||
515 | public function getLeafCategory() |
||
516 | { |
||
517 | return $this->LeafCategory; |
||
518 | } |
||
519 | /** |
||
520 | * Set LeafCategory value |
||
521 | * @param bool $leafCategory |
||
522 | * @return \PayPal\StructType\CategoryType |
||
523 | */ |
||
524 | public function setLeafCategory($leafCategory = null) |
||
532 | } |
||
533 | /** |
||
534 | * Get Virtual value |
||
535 | * @return bool|null |
||
536 | */ |
||
537 | public function getVirtual() |
||
538 | { |
||
539 | return $this->Virtual; |
||
540 | } |
||
541 | /** |
||
542 | * Set Virtual value |
||
543 | * @param bool $virtual |
||
544 | * @return \PayPal\StructType\CategoryType |
||
545 | */ |
||
546 | public function setVirtual($virtual = null) |
||
547 | { |
||
548 | // validation for constraint: boolean |
||
549 | if (!is_null($virtual) && !is_bool($virtual)) { |
||
550 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($virtual, true), gettype($virtual)), __LINE__); |
||
554 | } |
||
555 | } |
||
556 |