Total Complexity | 67 |
Total Lines | 436 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like BMSetInventoryRequestType 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 BMSetInventoryRequestType, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class BMSetInventoryRequestType extends AbstractRequestType |
||
13 | { |
||
14 | /** |
||
15 | * The HostedButtonID |
||
16 | * Meta information extracted from the WSDL |
||
17 | * - documentation: Hosted Button ID of button you wish to change. Required Character length and limitations: 10 single-byte numeric characters |
||
18 | * - maxOccurs: 1 |
||
19 | * - minOccurs: 1 |
||
20 | * @var string |
||
21 | */ |
||
22 | public $HostedButtonID; |
||
23 | /** |
||
24 | * The TrackInv |
||
25 | * Meta information extracted from the WSDL |
||
26 | * - documentation: Is Inventory tracked. Required 0 or 1 |
||
27 | * - maxOccurs: 1 |
||
28 | * - minOccurs: 1 |
||
29 | * @var string |
||
30 | */ |
||
31 | public $TrackInv; |
||
32 | /** |
||
33 | * The TrackPnl |
||
34 | * Meta information extracted from the WSDL |
||
35 | * - documentation: Is PNL Tracked. Required 0 or 1 |
||
36 | * - maxOccurs: 1 |
||
37 | * - minOccurs: 1 |
||
38 | * @var string |
||
39 | */ |
||
40 | public $TrackPnl; |
||
41 | /** |
||
42 | * The ItemTrackingDetails |
||
43 | * Meta information extracted from the WSDL |
||
44 | * - maxOccurs: 1 |
||
45 | * - minOccurs: 0 |
||
46 | * - ref: ebl:ItemTrackingDetails |
||
47 | * @var \PayPal\StructType\ItemTrackingDetailsType |
||
48 | */ |
||
49 | public $ItemTrackingDetails; |
||
50 | /** |
||
51 | * The OptionIndex |
||
52 | * Meta information extracted from the WSDL |
||
53 | * - documentation: Option Index. Optional Character length and limitations: 1 single-byte alphanumeric characters |
||
54 | * - maxOccurs: 1 |
||
55 | * - minOccurs: 0 |
||
56 | * @var string |
||
57 | */ |
||
58 | public $OptionIndex; |
||
59 | /** |
||
60 | * The OptionTrackingDetails |
||
61 | * Meta information extracted from the WSDL |
||
62 | * - maxOccurs: 10 |
||
63 | * - minOccurs: 0 |
||
64 | * - ref: ebl:OptionTrackingDetails |
||
65 | * @var \PayPal\StructType\OptionTrackingDetailsType[] |
||
66 | */ |
||
67 | public $OptionTrackingDetails; |
||
68 | /** |
||
69 | * The SoldoutURL |
||
70 | * Meta information extracted from the WSDL |
||
71 | * - documentation: URL of page to display when an item is soldout. Optional Character length and limitations: 127 single-byte alphanumeric characters |
||
72 | * - maxOccurs: 1 |
||
73 | * - minOccurs: 0 |
||
74 | * @var string |
||
75 | */ |
||
76 | public $SoldoutURL; |
||
77 | /** |
||
78 | * The ReuseDigitalDownloadKeys |
||
79 | * Meta information extracted from the WSDL |
||
80 | * - documentation: Whether to use the same digital download key repeatedly. Optional |
||
81 | * - maxOccurs: 1 |
||
82 | * - minOccurs: 0 |
||
83 | * @var string |
||
84 | */ |
||
85 | public $ReuseDigitalDownloadKeys; |
||
86 | /** |
||
87 | * The AppendDigitalDownloadKeys |
||
88 | * Meta information extracted from the WSDL |
||
89 | * - documentation: Whether to append these keys to the list or not (replace). Optional |
||
90 | * - maxOccurs: 1 |
||
91 | * - minOccurs: 0 |
||
92 | * @var string |
||
93 | */ |
||
94 | public $AppendDigitalDownloadKeys; |
||
95 | /** |
||
96 | * The DigitalDownloadKeys |
||
97 | * Meta information extracted from the WSDL |
||
98 | * - documentation: Zero or more digital download keys to distribute to customers after transaction is completed. Optional Character length and limitations: 1000 single-byte alphanumeric characters |
||
99 | * - maxOccurs: 1000 |
||
100 | * - minOccurs: 0 |
||
101 | * @var string[] |
||
102 | */ |
||
103 | public $DigitalDownloadKeys; |
||
104 | /** |
||
105 | * Constructor method for BMSetInventoryRequestType |
||
106 | * @uses BMSetInventoryRequestType::setHostedButtonID() |
||
107 | * @uses BMSetInventoryRequestType::setTrackInv() |
||
108 | * @uses BMSetInventoryRequestType::setTrackPnl() |
||
109 | * @uses BMSetInventoryRequestType::setItemTrackingDetails() |
||
110 | * @uses BMSetInventoryRequestType::setOptionIndex() |
||
111 | * @uses BMSetInventoryRequestType::setOptionTrackingDetails() |
||
112 | * @uses BMSetInventoryRequestType::setSoldoutURL() |
||
113 | * @uses BMSetInventoryRequestType::setReuseDigitalDownloadKeys() |
||
114 | * @uses BMSetInventoryRequestType::setAppendDigitalDownloadKeys() |
||
115 | * @uses BMSetInventoryRequestType::setDigitalDownloadKeys() |
||
116 | * @param string $hostedButtonID |
||
117 | * @param string $trackInv |
||
118 | * @param string $trackPnl |
||
119 | * @param \PayPal\StructType\ItemTrackingDetailsType $itemTrackingDetails |
||
120 | * @param string $optionIndex |
||
121 | * @param \PayPal\StructType\OptionTrackingDetailsType[] $optionTrackingDetails |
||
122 | * @param string $soldoutURL |
||
123 | * @param string $reuseDigitalDownloadKeys |
||
124 | * @param string $appendDigitalDownloadKeys |
||
125 | * @param string[] $digitalDownloadKeys |
||
126 | */ |
||
127 | public function __construct($hostedButtonID = null, $trackInv = null, $trackPnl = null, \PayPal\StructType\ItemTrackingDetailsType $itemTrackingDetails = null, $optionIndex = null, array $optionTrackingDetails = array(), $soldoutURL = null, $reuseDigitalDownloadKeys = null, $appendDigitalDownloadKeys = null, array $digitalDownloadKeys = array()) |
||
128 | { |
||
129 | $this |
||
130 | ->setHostedButtonID($hostedButtonID) |
||
131 | ->setTrackInv($trackInv) |
||
132 | ->setTrackPnl($trackPnl) |
||
133 | ->setItemTrackingDetails($itemTrackingDetails) |
||
134 | ->setOptionIndex($optionIndex) |
||
135 | ->setOptionTrackingDetails($optionTrackingDetails) |
||
136 | ->setSoldoutURL($soldoutURL) |
||
137 | ->setReuseDigitalDownloadKeys($reuseDigitalDownloadKeys) |
||
138 | ->setAppendDigitalDownloadKeys($appendDigitalDownloadKeys) |
||
139 | ->setDigitalDownloadKeys($digitalDownloadKeys); |
||
140 | } |
||
141 | /** |
||
142 | * Get HostedButtonID value |
||
143 | * @return string |
||
144 | */ |
||
145 | public function getHostedButtonID() |
||
146 | { |
||
147 | return $this->HostedButtonID; |
||
148 | } |
||
149 | /** |
||
150 | * Set HostedButtonID value |
||
151 | * @param string $hostedButtonID |
||
152 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
153 | */ |
||
154 | public function setHostedButtonID($hostedButtonID = null) |
||
155 | { |
||
156 | // validation for constraint: string |
||
157 | if (!is_null($hostedButtonID) && !is_string($hostedButtonID)) { |
||
|
|||
158 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($hostedButtonID, true), gettype($hostedButtonID)), __LINE__); |
||
159 | } |
||
160 | $this->HostedButtonID = $hostedButtonID; |
||
161 | return $this; |
||
162 | } |
||
163 | /** |
||
164 | * Get TrackInv value |
||
165 | * @return string |
||
166 | */ |
||
167 | public function getTrackInv() |
||
168 | { |
||
169 | return $this->TrackInv; |
||
170 | } |
||
171 | /** |
||
172 | * Set TrackInv value |
||
173 | * @param string $trackInv |
||
174 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
175 | */ |
||
176 | public function setTrackInv($trackInv = null) |
||
177 | { |
||
178 | // validation for constraint: string |
||
179 | if (!is_null($trackInv) && !is_string($trackInv)) { |
||
180 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trackInv, true), gettype($trackInv)), __LINE__); |
||
181 | } |
||
182 | $this->TrackInv = $trackInv; |
||
183 | return $this; |
||
184 | } |
||
185 | /** |
||
186 | * Get TrackPnl value |
||
187 | * @return string |
||
188 | */ |
||
189 | public function getTrackPnl() |
||
190 | { |
||
191 | return $this->TrackPnl; |
||
192 | } |
||
193 | /** |
||
194 | * Set TrackPnl value |
||
195 | * @param string $trackPnl |
||
196 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
197 | */ |
||
198 | public function setTrackPnl($trackPnl = null) |
||
199 | { |
||
200 | // validation for constraint: string |
||
201 | if (!is_null($trackPnl) && !is_string($trackPnl)) { |
||
202 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trackPnl, true), gettype($trackPnl)), __LINE__); |
||
203 | } |
||
204 | $this->TrackPnl = $trackPnl; |
||
205 | return $this; |
||
206 | } |
||
207 | /** |
||
208 | * Get ItemTrackingDetails value |
||
209 | * @return \PayPal\StructType\ItemTrackingDetailsType|null |
||
210 | */ |
||
211 | public function getItemTrackingDetails() |
||
212 | { |
||
213 | return $this->ItemTrackingDetails; |
||
214 | } |
||
215 | /** |
||
216 | * Set ItemTrackingDetails value |
||
217 | * @param \PayPal\StructType\ItemTrackingDetailsType $itemTrackingDetails |
||
218 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
219 | */ |
||
220 | public function setItemTrackingDetails(\PayPal\StructType\ItemTrackingDetailsType $itemTrackingDetails = null) |
||
221 | { |
||
222 | $this->ItemTrackingDetails = $itemTrackingDetails; |
||
223 | return $this; |
||
224 | } |
||
225 | /** |
||
226 | * Get OptionIndex value |
||
227 | * @return string|null |
||
228 | */ |
||
229 | public function getOptionIndex() |
||
230 | { |
||
231 | return $this->OptionIndex; |
||
232 | } |
||
233 | /** |
||
234 | * Set OptionIndex value |
||
235 | * @param string $optionIndex |
||
236 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
237 | */ |
||
238 | public function setOptionIndex($optionIndex = null) |
||
239 | { |
||
240 | // validation for constraint: string |
||
241 | if (!is_null($optionIndex) && !is_string($optionIndex)) { |
||
242 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($optionIndex, true), gettype($optionIndex)), __LINE__); |
||
243 | } |
||
244 | $this->OptionIndex = $optionIndex; |
||
245 | return $this; |
||
246 | } |
||
247 | /** |
||
248 | * Get OptionTrackingDetails value |
||
249 | * @return \PayPal\StructType\OptionTrackingDetailsType[]|null |
||
250 | */ |
||
251 | public function getOptionTrackingDetails() |
||
252 | { |
||
253 | return $this->OptionTrackingDetails; |
||
254 | } |
||
255 | /** |
||
256 | * This method is responsible for validating the values passed to the setOptionTrackingDetails method |
||
257 | * This method is willingly generated in order to preserve the one-line inline validation within the setOptionTrackingDetails method |
||
258 | * @param array $values |
||
259 | * @return string A non-empty message if the values does not match the validation rules |
||
260 | */ |
||
261 | public static function validateOptionTrackingDetailsForArrayConstraintsFromSetOptionTrackingDetails(array $values = array()) |
||
262 | { |
||
263 | $message = ''; |
||
264 | $invalidValues = []; |
||
265 | foreach ($values as $bMSetInventoryRequestTypeOptionTrackingDetailsItem) { |
||
266 | // validation for constraint: itemType |
||
267 | if (!$bMSetInventoryRequestTypeOptionTrackingDetailsItem instanceof \PayPal\StructType\OptionTrackingDetailsType) { |
||
268 | $invalidValues[] = is_object($bMSetInventoryRequestTypeOptionTrackingDetailsItem) ? get_class($bMSetInventoryRequestTypeOptionTrackingDetailsItem) : sprintf('%s(%s)', gettype($bMSetInventoryRequestTypeOptionTrackingDetailsItem), var_export($bMSetInventoryRequestTypeOptionTrackingDetailsItem, true)); |
||
269 | } |
||
270 | } |
||
271 | if (!empty($invalidValues)) { |
||
272 | $message = sprintf('The OptionTrackingDetails property can only contain items of type \PayPal\StructType\OptionTrackingDetailsType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
273 | } |
||
274 | unset($invalidValues); |
||
275 | return $message; |
||
276 | } |
||
277 | /** |
||
278 | * Set OptionTrackingDetails value |
||
279 | * @throws \InvalidArgumentException |
||
280 | * @param \PayPal\StructType\OptionTrackingDetailsType[] $optionTrackingDetails |
||
281 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
282 | */ |
||
283 | public function setOptionTrackingDetails(array $optionTrackingDetails = array()) |
||
284 | { |
||
285 | // validation for constraint: array |
||
286 | if ('' !== ($optionTrackingDetailsArrayErrorMessage = self::validateOptionTrackingDetailsForArrayConstraintsFromSetOptionTrackingDetails($optionTrackingDetails))) { |
||
287 | throw new \InvalidArgumentException($optionTrackingDetailsArrayErrorMessage, __LINE__); |
||
288 | } |
||
289 | // validation for constraint: maxOccurs(10) |
||
290 | if (is_array($optionTrackingDetails) && count($optionTrackingDetails) > 10) { |
||
291 | throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 10', count($optionTrackingDetails)), __LINE__); |
||
292 | } |
||
293 | $this->OptionTrackingDetails = $optionTrackingDetails; |
||
294 | return $this; |
||
295 | } |
||
296 | /** |
||
297 | * Add item to OptionTrackingDetails value |
||
298 | * @throws \InvalidArgumentException |
||
299 | * @param \PayPal\StructType\OptionTrackingDetailsType $item |
||
300 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
301 | */ |
||
302 | public function addToOptionTrackingDetails(\PayPal\StructType\OptionTrackingDetailsType $item) |
||
314 | } |
||
315 | /** |
||
316 | * Get SoldoutURL value |
||
317 | * @return string|null |
||
318 | */ |
||
319 | public function getSoldoutURL() |
||
320 | { |
||
321 | return $this->SoldoutURL; |
||
322 | } |
||
323 | /** |
||
324 | * Set SoldoutURL value |
||
325 | * @param string $soldoutURL |
||
326 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
327 | */ |
||
328 | public function setSoldoutURL($soldoutURL = null) |
||
329 | { |
||
330 | // validation for constraint: string |
||
331 | if (!is_null($soldoutURL) && !is_string($soldoutURL)) { |
||
332 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($soldoutURL, true), gettype($soldoutURL)), __LINE__); |
||
333 | } |
||
334 | $this->SoldoutURL = $soldoutURL; |
||
335 | return $this; |
||
336 | } |
||
337 | /** |
||
338 | * Get ReuseDigitalDownloadKeys value |
||
339 | * @return string|null |
||
340 | */ |
||
341 | public function getReuseDigitalDownloadKeys() |
||
344 | } |
||
345 | /** |
||
346 | * Set ReuseDigitalDownloadKeys value |
||
347 | * @param string $reuseDigitalDownloadKeys |
||
348 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
349 | */ |
||
350 | public function setReuseDigitalDownloadKeys($reuseDigitalDownloadKeys = null) |
||
351 | { |
||
352 | // validation for constraint: string |
||
353 | if (!is_null($reuseDigitalDownloadKeys) && !is_string($reuseDigitalDownloadKeys)) { |
||
354 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($reuseDigitalDownloadKeys, true), gettype($reuseDigitalDownloadKeys)), __LINE__); |
||
355 | } |
||
356 | $this->ReuseDigitalDownloadKeys = $reuseDigitalDownloadKeys; |
||
357 | return $this; |
||
358 | } |
||
359 | /** |
||
360 | * Get AppendDigitalDownloadKeys value |
||
361 | * @return string|null |
||
362 | */ |
||
363 | public function getAppendDigitalDownloadKeys() |
||
364 | { |
||
365 | return $this->AppendDigitalDownloadKeys; |
||
366 | } |
||
367 | /** |
||
368 | * Set AppendDigitalDownloadKeys value |
||
369 | * @param string $appendDigitalDownloadKeys |
||
370 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
371 | */ |
||
372 | public function setAppendDigitalDownloadKeys($appendDigitalDownloadKeys = null) |
||
373 | { |
||
374 | // validation for constraint: string |
||
375 | if (!is_null($appendDigitalDownloadKeys) && !is_string($appendDigitalDownloadKeys)) { |
||
376 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($appendDigitalDownloadKeys, true), gettype($appendDigitalDownloadKeys)), __LINE__); |
||
377 | } |
||
378 | $this->AppendDigitalDownloadKeys = $appendDigitalDownloadKeys; |
||
379 | return $this; |
||
380 | } |
||
381 | /** |
||
382 | * Get DigitalDownloadKeys value |
||
383 | * @return string[]|null |
||
384 | */ |
||
385 | public function getDigitalDownloadKeys() |
||
386 | { |
||
387 | return $this->DigitalDownloadKeys; |
||
388 | } |
||
389 | /** |
||
390 | * This method is responsible for validating the values passed to the setDigitalDownloadKeys method |
||
391 | * This method is willingly generated in order to preserve the one-line inline validation within the setDigitalDownloadKeys method |
||
392 | * @param array $values |
||
393 | * @return string A non-empty message if the values does not match the validation rules |
||
394 | */ |
||
395 | public static function validateDigitalDownloadKeysForArrayConstraintsFromSetDigitalDownloadKeys(array $values = array()) |
||
396 | { |
||
397 | $message = ''; |
||
398 | $invalidValues = []; |
||
399 | foreach ($values as $bMSetInventoryRequestTypeDigitalDownloadKeysItem) { |
||
400 | // validation for constraint: itemType |
||
401 | if (!is_string($bMSetInventoryRequestTypeDigitalDownloadKeysItem)) { |
||
402 | $invalidValues[] = is_object($bMSetInventoryRequestTypeDigitalDownloadKeysItem) ? get_class($bMSetInventoryRequestTypeDigitalDownloadKeysItem) : sprintf('%s(%s)', gettype($bMSetInventoryRequestTypeDigitalDownloadKeysItem), var_export($bMSetInventoryRequestTypeDigitalDownloadKeysItem, true)); |
||
403 | } |
||
404 | } |
||
405 | if (!empty($invalidValues)) { |
||
406 | $message = sprintf('The DigitalDownloadKeys property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
407 | } |
||
408 | unset($invalidValues); |
||
409 | return $message; |
||
410 | } |
||
411 | /** |
||
412 | * Set DigitalDownloadKeys value |
||
413 | * @throws \InvalidArgumentException |
||
414 | * @param string[] $digitalDownloadKeys |
||
415 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
416 | */ |
||
417 | public function setDigitalDownloadKeys(array $digitalDownloadKeys = array()) |
||
429 | } |
||
430 | /** |
||
431 | * Add item to DigitalDownloadKeys value |
||
432 | * @throws \InvalidArgumentException |
||
433 | * @param string $item |
||
434 | * @return \PayPal\StructType\BMSetInventoryRequestType |
||
435 | */ |
||
436 | public function addToDigitalDownloadKeys($item) |
||
437 | { |
||
438 | // validation for constraint: itemType |
||
448 | } |
||
449 | } |
||
450 |