Total Complexity | 63 |
Total Lines | 336 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like GetIncentiveEvaluationRequestDetailsType 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 GetIncentiveEvaluationRequestDetailsType, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class GetIncentiveEvaluationRequestDetailsType extends AbstractStructBase |
||
13 | { |
||
14 | /** |
||
15 | * The ExternalBuyerId |
||
16 | * Meta information extracted from the WSDL |
||
17 | * - maxOccurs: 1 |
||
18 | * - minOccurs: 0 |
||
19 | * @var string |
||
20 | */ |
||
21 | public $ExternalBuyerId; |
||
22 | /** |
||
23 | * The IncentiveCodes |
||
24 | * Meta information extracted from the WSDL |
||
25 | * - maxOccurs: 1000 |
||
26 | * - minOccurs: 0 |
||
27 | * @var string[] |
||
28 | */ |
||
29 | public $IncentiveCodes; |
||
30 | /** |
||
31 | * The ApplyIndication |
||
32 | * Meta information extracted from the WSDL |
||
33 | * - maxOccurs: 1000 |
||
34 | * - minOccurs: 0 |
||
35 | * @var \PayPal\StructType\IncentiveApplyIndicationType[] |
||
36 | */ |
||
37 | public $ApplyIndication; |
||
38 | /** |
||
39 | * The Buckets |
||
40 | * Meta information extracted from the WSDL |
||
41 | * - maxOccurs: 100 |
||
42 | * - minOccurs: 0 |
||
43 | * @var \PayPal\StructType\IncentiveBucketType[] |
||
44 | */ |
||
45 | public $Buckets; |
||
46 | /** |
||
47 | * The CartTotalAmt |
||
48 | * Meta information extracted from the WSDL |
||
49 | * - maxOccurs: 1 |
||
50 | * - minOccurs: 0 |
||
51 | * @var \PayPal\StructType\BasicAmountType |
||
52 | */ |
||
53 | public $CartTotalAmt; |
||
54 | /** |
||
55 | * The RequestDetails |
||
56 | * Meta information extracted from the WSDL |
||
57 | * - maxOccurs: 1 |
||
58 | * - minOccurs: 0 |
||
59 | * @var \PayPal\StructType\IncentiveRequestDetailsType |
||
60 | */ |
||
61 | public $RequestDetails; |
||
62 | /** |
||
63 | * Constructor method for GetIncentiveEvaluationRequestDetailsType |
||
64 | * @uses GetIncentiveEvaluationRequestDetailsType::setExternalBuyerId() |
||
65 | * @uses GetIncentiveEvaluationRequestDetailsType::setIncentiveCodes() |
||
66 | * @uses GetIncentiveEvaluationRequestDetailsType::setApplyIndication() |
||
67 | * @uses GetIncentiveEvaluationRequestDetailsType::setBuckets() |
||
68 | * @uses GetIncentiveEvaluationRequestDetailsType::setCartTotalAmt() |
||
69 | * @uses GetIncentiveEvaluationRequestDetailsType::setRequestDetails() |
||
70 | * @param string $externalBuyerId |
||
71 | * @param string[] $incentiveCodes |
||
72 | * @param \PayPal\StructType\IncentiveApplyIndicationType[] $applyIndication |
||
73 | * @param \PayPal\StructType\IncentiveBucketType[] $buckets |
||
74 | * @param \PayPal\StructType\BasicAmountType $cartTotalAmt |
||
75 | * @param \PayPal\StructType\IncentiveRequestDetailsType $requestDetails |
||
76 | */ |
||
77 | public function __construct($externalBuyerId = null, array $incentiveCodes = array(), array $applyIndication = array(), array $buckets = array(), \PayPal\StructType\BasicAmountType $cartTotalAmt = null, \PayPal\StructType\IncentiveRequestDetailsType $requestDetails = null) |
||
78 | { |
||
79 | $this |
||
80 | ->setExternalBuyerId($externalBuyerId) |
||
81 | ->setIncentiveCodes($incentiveCodes) |
||
82 | ->setApplyIndication($applyIndication) |
||
83 | ->setBuckets($buckets) |
||
84 | ->setCartTotalAmt($cartTotalAmt) |
||
85 | ->setRequestDetails($requestDetails); |
||
86 | } |
||
87 | /** |
||
88 | * Get ExternalBuyerId value |
||
89 | * @return string|null |
||
90 | */ |
||
91 | public function getExternalBuyerId() |
||
92 | { |
||
93 | return $this->ExternalBuyerId; |
||
94 | } |
||
95 | /** |
||
96 | * Set ExternalBuyerId value |
||
97 | * @param string $externalBuyerId |
||
98 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
99 | */ |
||
100 | public function setExternalBuyerId($externalBuyerId = null) |
||
101 | { |
||
102 | // validation for constraint: string |
||
103 | if (!is_null($externalBuyerId) && !is_string($externalBuyerId)) { |
||
|
|||
104 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($externalBuyerId, true), gettype($externalBuyerId)), __LINE__); |
||
105 | } |
||
106 | $this->ExternalBuyerId = $externalBuyerId; |
||
107 | return $this; |
||
108 | } |
||
109 | /** |
||
110 | * Get IncentiveCodes value |
||
111 | * @return string[]|null |
||
112 | */ |
||
113 | public function getIncentiveCodes() |
||
114 | { |
||
115 | return $this->IncentiveCodes; |
||
116 | } |
||
117 | /** |
||
118 | * This method is responsible for validating the values passed to the setIncentiveCodes method |
||
119 | * This method is willingly generated in order to preserve the one-line inline validation within the setIncentiveCodes method |
||
120 | * @param array $values |
||
121 | * @return string A non-empty message if the values does not match the validation rules |
||
122 | */ |
||
123 | public static function validateIncentiveCodesForArrayConstraintsFromSetIncentiveCodes(array $values = array()) |
||
124 | { |
||
125 | $message = ''; |
||
126 | $invalidValues = []; |
||
127 | foreach ($values as $getIncentiveEvaluationRequestDetailsTypeIncentiveCodesItem) { |
||
128 | // validation for constraint: itemType |
||
129 | if (!is_string($getIncentiveEvaluationRequestDetailsTypeIncentiveCodesItem)) { |
||
130 | $invalidValues[] = is_object($getIncentiveEvaluationRequestDetailsTypeIncentiveCodesItem) ? get_class($getIncentiveEvaluationRequestDetailsTypeIncentiveCodesItem) : sprintf('%s(%s)', gettype($getIncentiveEvaluationRequestDetailsTypeIncentiveCodesItem), var_export($getIncentiveEvaluationRequestDetailsTypeIncentiveCodesItem, true)); |
||
131 | } |
||
132 | } |
||
133 | if (!empty($invalidValues)) { |
||
134 | $message = sprintf('The IncentiveCodes property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
135 | } |
||
136 | unset($invalidValues); |
||
137 | return $message; |
||
138 | } |
||
139 | /** |
||
140 | * Set IncentiveCodes value |
||
141 | * @throws \InvalidArgumentException |
||
142 | * @param string[] $incentiveCodes |
||
143 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
144 | */ |
||
145 | public function setIncentiveCodes(array $incentiveCodes = array()) |
||
146 | { |
||
147 | // validation for constraint: array |
||
148 | if ('' !== ($incentiveCodesArrayErrorMessage = self::validateIncentiveCodesForArrayConstraintsFromSetIncentiveCodes($incentiveCodes))) { |
||
149 | throw new \InvalidArgumentException($incentiveCodesArrayErrorMessage, __LINE__); |
||
150 | } |
||
151 | // validation for constraint: maxOccurs(1000) |
||
152 | if (is_array($incentiveCodes) && count($incentiveCodes) > 1000) { |
||
153 | throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 1000', count($incentiveCodes)), __LINE__); |
||
154 | } |
||
155 | $this->IncentiveCodes = $incentiveCodes; |
||
156 | return $this; |
||
157 | } |
||
158 | /** |
||
159 | * Add item to IncentiveCodes value |
||
160 | * @throws \InvalidArgumentException |
||
161 | * @param string $item |
||
162 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
163 | */ |
||
164 | public function addToIncentiveCodes($item) |
||
165 | { |
||
166 | // validation for constraint: itemType |
||
167 | if (!is_string($item)) { |
||
168 | throw new \InvalidArgumentException(sprintf('The IncentiveCodes property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
169 | } |
||
170 | // validation for constraint: maxOccurs(1000) |
||
171 | if (is_array($this->IncentiveCodes) && count($this->IncentiveCodes) >= 1000) { |
||
172 | throw new \InvalidArgumentException(sprintf('You can\'t add anymore element to this property that already contains %s elements, the number of elements contained by the property must be less than or equal to 1000', count($this->IncentiveCodes)), __LINE__); |
||
173 | } |
||
174 | $this->IncentiveCodes[] = $item; |
||
175 | return $this; |
||
176 | } |
||
177 | /** |
||
178 | * Get ApplyIndication value |
||
179 | * @return \PayPal\StructType\IncentiveApplyIndicationType[]|null |
||
180 | */ |
||
181 | public function getApplyIndication() |
||
182 | { |
||
183 | return $this->ApplyIndication; |
||
184 | } |
||
185 | /** |
||
186 | * This method is responsible for validating the values passed to the setApplyIndication method |
||
187 | * This method is willingly generated in order to preserve the one-line inline validation within the setApplyIndication method |
||
188 | * @param array $values |
||
189 | * @return string A non-empty message if the values does not match the validation rules |
||
190 | */ |
||
191 | public static function validateApplyIndicationForArrayConstraintsFromSetApplyIndication(array $values = array()) |
||
192 | { |
||
193 | $message = ''; |
||
194 | $invalidValues = []; |
||
195 | foreach ($values as $getIncentiveEvaluationRequestDetailsTypeApplyIndicationItem) { |
||
196 | // validation for constraint: itemType |
||
197 | if (!$getIncentiveEvaluationRequestDetailsTypeApplyIndicationItem instanceof \PayPal\StructType\IncentiveApplyIndicationType) { |
||
198 | $invalidValues[] = is_object($getIncentiveEvaluationRequestDetailsTypeApplyIndicationItem) ? get_class($getIncentiveEvaluationRequestDetailsTypeApplyIndicationItem) : sprintf('%s(%s)', gettype($getIncentiveEvaluationRequestDetailsTypeApplyIndicationItem), var_export($getIncentiveEvaluationRequestDetailsTypeApplyIndicationItem, true)); |
||
199 | } |
||
200 | } |
||
201 | if (!empty($invalidValues)) { |
||
202 | $message = sprintf('The ApplyIndication property can only contain items of type \PayPal\StructType\IncentiveApplyIndicationType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
203 | } |
||
204 | unset($invalidValues); |
||
205 | return $message; |
||
206 | } |
||
207 | /** |
||
208 | * Set ApplyIndication value |
||
209 | * @throws \InvalidArgumentException |
||
210 | * @param \PayPal\StructType\IncentiveApplyIndicationType[] $applyIndication |
||
211 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
212 | */ |
||
213 | public function setApplyIndication(array $applyIndication = array()) |
||
214 | { |
||
215 | // validation for constraint: array |
||
216 | if ('' !== ($applyIndicationArrayErrorMessage = self::validateApplyIndicationForArrayConstraintsFromSetApplyIndication($applyIndication))) { |
||
217 | throw new \InvalidArgumentException($applyIndicationArrayErrorMessage, __LINE__); |
||
218 | } |
||
219 | // validation for constraint: maxOccurs(1000) |
||
220 | if (is_array($applyIndication) && count($applyIndication) > 1000) { |
||
221 | throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 1000', count($applyIndication)), __LINE__); |
||
222 | } |
||
223 | $this->ApplyIndication = $applyIndication; |
||
224 | return $this; |
||
225 | } |
||
226 | /** |
||
227 | * Add item to ApplyIndication value |
||
228 | * @throws \InvalidArgumentException |
||
229 | * @param \PayPal\StructType\IncentiveApplyIndicationType $item |
||
230 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
231 | */ |
||
232 | public function addToApplyIndication(\PayPal\StructType\IncentiveApplyIndicationType $item) |
||
233 | { |
||
234 | // validation for constraint: itemType |
||
235 | if (!$item instanceof \PayPal\StructType\IncentiveApplyIndicationType) { |
||
236 | throw new \InvalidArgumentException(sprintf('The ApplyIndication property can only contain items of type \PayPal\StructType\IncentiveApplyIndicationType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
237 | } |
||
238 | // validation for constraint: maxOccurs(1000) |
||
239 | if (is_array($this->ApplyIndication) && count($this->ApplyIndication) >= 1000) { |
||
240 | throw new \InvalidArgumentException(sprintf('You can\'t add anymore element to this property that already contains %s elements, the number of elements contained by the property must be less than or equal to 1000', count($this->ApplyIndication)), __LINE__); |
||
241 | } |
||
242 | $this->ApplyIndication[] = $item; |
||
243 | return $this; |
||
244 | } |
||
245 | /** |
||
246 | * Get Buckets value |
||
247 | * @return \PayPal\StructType\IncentiveBucketType[]|null |
||
248 | */ |
||
249 | public function getBuckets() |
||
250 | { |
||
251 | return $this->Buckets; |
||
252 | } |
||
253 | /** |
||
254 | * This method is responsible for validating the values passed to the setBuckets method |
||
255 | * This method is willingly generated in order to preserve the one-line inline validation within the setBuckets method |
||
256 | * @param array $values |
||
257 | * @return string A non-empty message if the values does not match the validation rules |
||
258 | */ |
||
259 | public static function validateBucketsForArrayConstraintsFromSetBuckets(array $values = array()) |
||
260 | { |
||
261 | $message = ''; |
||
262 | $invalidValues = []; |
||
263 | foreach ($values as $getIncentiveEvaluationRequestDetailsTypeBucketsItem) { |
||
264 | // validation for constraint: itemType |
||
265 | if (!$getIncentiveEvaluationRequestDetailsTypeBucketsItem instanceof \PayPal\StructType\IncentiveBucketType) { |
||
266 | $invalidValues[] = is_object($getIncentiveEvaluationRequestDetailsTypeBucketsItem) ? get_class($getIncentiveEvaluationRequestDetailsTypeBucketsItem) : sprintf('%s(%s)', gettype($getIncentiveEvaluationRequestDetailsTypeBucketsItem), var_export($getIncentiveEvaluationRequestDetailsTypeBucketsItem, true)); |
||
267 | } |
||
268 | } |
||
269 | if (!empty($invalidValues)) { |
||
270 | $message = sprintf('The Buckets property can only contain items of type \PayPal\StructType\IncentiveBucketType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
271 | } |
||
272 | unset($invalidValues); |
||
273 | return $message; |
||
274 | } |
||
275 | /** |
||
276 | * Set Buckets value |
||
277 | * @throws \InvalidArgumentException |
||
278 | * @param \PayPal\StructType\IncentiveBucketType[] $buckets |
||
279 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
280 | */ |
||
281 | public function setBuckets(array $buckets = array()) |
||
282 | { |
||
283 | // validation for constraint: array |
||
284 | if ('' !== ($bucketsArrayErrorMessage = self::validateBucketsForArrayConstraintsFromSetBuckets($buckets))) { |
||
285 | throw new \InvalidArgumentException($bucketsArrayErrorMessage, __LINE__); |
||
286 | } |
||
287 | // validation for constraint: maxOccurs(100) |
||
288 | if (is_array($buckets) && count($buckets) > 100) { |
||
289 | throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 100', count($buckets)), __LINE__); |
||
290 | } |
||
291 | $this->Buckets = $buckets; |
||
292 | return $this; |
||
293 | } |
||
294 | /** |
||
295 | * Add item to Buckets value |
||
296 | * @throws \InvalidArgumentException |
||
297 | * @param \PayPal\StructType\IncentiveBucketType $item |
||
298 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
299 | */ |
||
300 | public function addToBuckets(\PayPal\StructType\IncentiveBucketType $item) |
||
312 | } |
||
313 | /** |
||
314 | * Get CartTotalAmt value |
||
315 | * @return \PayPal\StructType\BasicAmountType|null |
||
316 | */ |
||
317 | public function getCartTotalAmt() |
||
318 | { |
||
319 | return $this->CartTotalAmt; |
||
320 | } |
||
321 | /** |
||
322 | * Set CartTotalAmt value |
||
323 | * @param \PayPal\StructType\BasicAmountType $cartTotalAmt |
||
324 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
325 | */ |
||
326 | public function setCartTotalAmt(\PayPal\StructType\BasicAmountType $cartTotalAmt = null) |
||
330 | } |
||
331 | /** |
||
332 | * Get RequestDetails value |
||
333 | * @return \PayPal\StructType\IncentiveRequestDetailsType|null |
||
334 | */ |
||
335 | public function getRequestDetails() |
||
336 | { |
||
337 | return $this->RequestDetails; |
||
338 | } |
||
339 | /** |
||
340 | * Set RequestDetails value |
||
341 | * @param \PayPal\StructType\IncentiveRequestDetailsType $requestDetails |
||
342 | * @return \PayPal\StructType\GetIncentiveEvaluationRequestDetailsType |
||
343 | */ |
||
344 | public function setRequestDetails(\PayPal\StructType\IncentiveRequestDetailsType $requestDetails = null) |
||
348 | } |
||
349 | } |
||
350 |