Total Complexity | 63 |
Total Lines | 395 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like BMGetInventoryResponseType 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 BMGetInventoryResponseType, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class BMGetInventoryResponseType extends AbstractResponseType |
||
13 | { |
||
14 | /** |
||
15 | * The HostedButtonID |
||
16 | * Meta information extracted from the WSDL |
||
17 | * - maxOccurs: 1 |
||
18 | * - minOccurs: 1 |
||
19 | * @var string |
||
20 | */ |
||
21 | public $HostedButtonID; |
||
22 | /** |
||
23 | * The TrackInv |
||
24 | * Meta information extracted from the WSDL |
||
25 | * - maxOccurs: 1 |
||
26 | * - minOccurs: 1 |
||
27 | * @var string |
||
28 | */ |
||
29 | public $TrackInv; |
||
30 | /** |
||
31 | * The TrackPnl |
||
32 | * Meta information extracted from the WSDL |
||
33 | * - maxOccurs: 1 |
||
34 | * - minOccurs: 1 |
||
35 | * @var string |
||
36 | */ |
||
37 | public $TrackPnl; |
||
38 | /** |
||
39 | * The ItemTrackingDetails |
||
40 | * Meta information extracted from the WSDL |
||
41 | * - maxOccurs: 1 |
||
42 | * - minOccurs: 0 |
||
43 | * - ref: ebl:ItemTrackingDetails |
||
44 | * @var \PayPal\StructType\ItemTrackingDetailsType |
||
45 | */ |
||
46 | public $ItemTrackingDetails; |
||
47 | /** |
||
48 | * The OptionIndex |
||
49 | * Meta information extracted from the WSDL |
||
50 | * - maxOccurs: 1 |
||
51 | * - minOccurs: 0 |
||
52 | * @var string |
||
53 | */ |
||
54 | public $OptionIndex; |
||
55 | /** |
||
56 | * The OptionName |
||
57 | * Meta information extracted from the WSDL |
||
58 | * - maxOccurs: 1 |
||
59 | * - minOccurs: 0 |
||
60 | * @var string |
||
61 | */ |
||
62 | public $OptionName; |
||
63 | /** |
||
64 | * The OptionTrackingDetails |
||
65 | * Meta information extracted from the WSDL |
||
66 | * - maxOccurs: 10 |
||
67 | * - minOccurs: 0 |
||
68 | * - ref: ebl:OptionTrackingDetails |
||
69 | * @var \PayPal\StructType\OptionTrackingDetailsType[] |
||
70 | */ |
||
71 | public $OptionTrackingDetails; |
||
72 | /** |
||
73 | * The SoldoutURL |
||
74 | * Meta information extracted from the WSDL |
||
75 | * - maxOccurs: 1 |
||
76 | * - minOccurs: 0 |
||
77 | * @var string |
||
78 | */ |
||
79 | public $SoldoutURL; |
||
80 | /** |
||
81 | * The DigitalDownloadKeys |
||
82 | * Meta information extracted from the WSDL |
||
83 | * - maxOccurs: 1000 |
||
84 | * - minOccurs: 0 |
||
85 | * @var string[] |
||
86 | */ |
||
87 | public $DigitalDownloadKeys; |
||
88 | /** |
||
89 | * Constructor method for BMGetInventoryResponseType |
||
90 | * @uses BMGetInventoryResponseType::setHostedButtonID() |
||
91 | * @uses BMGetInventoryResponseType::setTrackInv() |
||
92 | * @uses BMGetInventoryResponseType::setTrackPnl() |
||
93 | * @uses BMGetInventoryResponseType::setItemTrackingDetails() |
||
94 | * @uses BMGetInventoryResponseType::setOptionIndex() |
||
95 | * @uses BMGetInventoryResponseType::setOptionName() |
||
96 | * @uses BMGetInventoryResponseType::setOptionTrackingDetails() |
||
97 | * @uses BMGetInventoryResponseType::setSoldoutURL() |
||
98 | * @uses BMGetInventoryResponseType::setDigitalDownloadKeys() |
||
99 | * @param string $hostedButtonID |
||
100 | * @param string $trackInv |
||
101 | * @param string $trackPnl |
||
102 | * @param \PayPal\StructType\ItemTrackingDetailsType $itemTrackingDetails |
||
103 | * @param string $optionIndex |
||
104 | * @param string $optionName |
||
105 | * @param \PayPal\StructType\OptionTrackingDetailsType[] $optionTrackingDetails |
||
106 | * @param string $soldoutURL |
||
107 | * @param string[] $digitalDownloadKeys |
||
108 | */ |
||
109 | public function __construct($hostedButtonID = null, $trackInv = null, $trackPnl = null, \PayPal\StructType\ItemTrackingDetailsType $itemTrackingDetails = null, $optionIndex = null, $optionName = null, array $optionTrackingDetails = array(), $soldoutURL = null, array $digitalDownloadKeys = array()) |
||
110 | { |
||
111 | $this |
||
112 | ->setHostedButtonID($hostedButtonID) |
||
113 | ->setTrackInv($trackInv) |
||
114 | ->setTrackPnl($trackPnl) |
||
115 | ->setItemTrackingDetails($itemTrackingDetails) |
||
116 | ->setOptionIndex($optionIndex) |
||
117 | ->setOptionName($optionName) |
||
118 | ->setOptionTrackingDetails($optionTrackingDetails) |
||
119 | ->setSoldoutURL($soldoutURL) |
||
120 | ->setDigitalDownloadKeys($digitalDownloadKeys); |
||
121 | } |
||
122 | /** |
||
123 | * Get HostedButtonID value |
||
124 | * @return string |
||
125 | */ |
||
126 | public function getHostedButtonID() |
||
127 | { |
||
128 | return $this->HostedButtonID; |
||
129 | } |
||
130 | /** |
||
131 | * Set HostedButtonID value |
||
132 | * @param string $hostedButtonID |
||
133 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
134 | */ |
||
135 | public function setHostedButtonID($hostedButtonID = null) |
||
136 | { |
||
137 | // validation for constraint: string |
||
138 | if (!is_null($hostedButtonID) && !is_string($hostedButtonID)) { |
||
|
|||
139 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($hostedButtonID, true), gettype($hostedButtonID)), __LINE__); |
||
140 | } |
||
141 | $this->HostedButtonID = $hostedButtonID; |
||
142 | return $this; |
||
143 | } |
||
144 | /** |
||
145 | * Get TrackInv value |
||
146 | * @return string |
||
147 | */ |
||
148 | public function getTrackInv() |
||
149 | { |
||
150 | return $this->TrackInv; |
||
151 | } |
||
152 | /** |
||
153 | * Set TrackInv value |
||
154 | * @param string $trackInv |
||
155 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
156 | */ |
||
157 | public function setTrackInv($trackInv = null) |
||
158 | { |
||
159 | // validation for constraint: string |
||
160 | if (!is_null($trackInv) && !is_string($trackInv)) { |
||
161 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trackInv, true), gettype($trackInv)), __LINE__); |
||
162 | } |
||
163 | $this->TrackInv = $trackInv; |
||
164 | return $this; |
||
165 | } |
||
166 | /** |
||
167 | * Get TrackPnl value |
||
168 | * @return string |
||
169 | */ |
||
170 | public function getTrackPnl() |
||
171 | { |
||
172 | return $this->TrackPnl; |
||
173 | } |
||
174 | /** |
||
175 | * Set TrackPnl value |
||
176 | * @param string $trackPnl |
||
177 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
178 | */ |
||
179 | public function setTrackPnl($trackPnl = null) |
||
180 | { |
||
181 | // validation for constraint: string |
||
182 | if (!is_null($trackPnl) && !is_string($trackPnl)) { |
||
183 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($trackPnl, true), gettype($trackPnl)), __LINE__); |
||
184 | } |
||
185 | $this->TrackPnl = $trackPnl; |
||
186 | return $this; |
||
187 | } |
||
188 | /** |
||
189 | * Get ItemTrackingDetails value |
||
190 | * @return \PayPal\StructType\ItemTrackingDetailsType|null |
||
191 | */ |
||
192 | public function getItemTrackingDetails() |
||
193 | { |
||
194 | return $this->ItemTrackingDetails; |
||
195 | } |
||
196 | /** |
||
197 | * Set ItemTrackingDetails value |
||
198 | * @param \PayPal\StructType\ItemTrackingDetailsType $itemTrackingDetails |
||
199 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
200 | */ |
||
201 | public function setItemTrackingDetails(\PayPal\StructType\ItemTrackingDetailsType $itemTrackingDetails = null) |
||
202 | { |
||
203 | $this->ItemTrackingDetails = $itemTrackingDetails; |
||
204 | return $this; |
||
205 | } |
||
206 | /** |
||
207 | * Get OptionIndex value |
||
208 | * @return string|null |
||
209 | */ |
||
210 | public function getOptionIndex() |
||
211 | { |
||
212 | return $this->OptionIndex; |
||
213 | } |
||
214 | /** |
||
215 | * Set OptionIndex value |
||
216 | * @param string $optionIndex |
||
217 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
218 | */ |
||
219 | public function setOptionIndex($optionIndex = null) |
||
220 | { |
||
221 | // validation for constraint: string |
||
222 | if (!is_null($optionIndex) && !is_string($optionIndex)) { |
||
223 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($optionIndex, true), gettype($optionIndex)), __LINE__); |
||
224 | } |
||
225 | $this->OptionIndex = $optionIndex; |
||
226 | return $this; |
||
227 | } |
||
228 | /** |
||
229 | * Get OptionName value |
||
230 | * @return string|null |
||
231 | */ |
||
232 | public function getOptionName() |
||
235 | } |
||
236 | /** |
||
237 | * Set OptionName value |
||
238 | * @param string $optionName |
||
239 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
240 | */ |
||
241 | public function setOptionName($optionName = null) |
||
242 | { |
||
243 | // validation for constraint: string |
||
244 | if (!is_null($optionName) && !is_string($optionName)) { |
||
245 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($optionName, true), gettype($optionName)), __LINE__); |
||
246 | } |
||
247 | $this->OptionName = $optionName; |
||
248 | return $this; |
||
249 | } |
||
250 | /** |
||
251 | * Get OptionTrackingDetails value |
||
252 | * @return \PayPal\StructType\OptionTrackingDetailsType[]|null |
||
253 | */ |
||
254 | public function getOptionTrackingDetails() |
||
255 | { |
||
256 | return $this->OptionTrackingDetails; |
||
257 | } |
||
258 | /** |
||
259 | * This method is responsible for validating the values passed to the setOptionTrackingDetails method |
||
260 | * This method is willingly generated in order to preserve the one-line inline validation within the setOptionTrackingDetails method |
||
261 | * @param array $values |
||
262 | * @return string A non-empty message if the values does not match the validation rules |
||
263 | */ |
||
264 | public static function validateOptionTrackingDetailsForArrayConstraintsFromSetOptionTrackingDetails(array $values = array()) |
||
265 | { |
||
266 | $message = ''; |
||
267 | $invalidValues = []; |
||
268 | foreach ($values as $bMGetInventoryResponseTypeOptionTrackingDetailsItem) { |
||
269 | // validation for constraint: itemType |
||
270 | if (!$bMGetInventoryResponseTypeOptionTrackingDetailsItem instanceof \PayPal\StructType\OptionTrackingDetailsType) { |
||
271 | $invalidValues[] = is_object($bMGetInventoryResponseTypeOptionTrackingDetailsItem) ? get_class($bMGetInventoryResponseTypeOptionTrackingDetailsItem) : sprintf('%s(%s)', gettype($bMGetInventoryResponseTypeOptionTrackingDetailsItem), var_export($bMGetInventoryResponseTypeOptionTrackingDetailsItem, true)); |
||
272 | } |
||
273 | } |
||
274 | if (!empty($invalidValues)) { |
||
275 | $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))); |
||
276 | } |
||
277 | unset($invalidValues); |
||
278 | return $message; |
||
279 | } |
||
280 | /** |
||
281 | * Set OptionTrackingDetails value |
||
282 | * @throws \InvalidArgumentException |
||
283 | * @param \PayPal\StructType\OptionTrackingDetailsType[] $optionTrackingDetails |
||
284 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
285 | */ |
||
286 | public function setOptionTrackingDetails(array $optionTrackingDetails = array()) |
||
287 | { |
||
288 | // validation for constraint: array |
||
289 | if ('' !== ($optionTrackingDetailsArrayErrorMessage = self::validateOptionTrackingDetailsForArrayConstraintsFromSetOptionTrackingDetails($optionTrackingDetails))) { |
||
290 | throw new \InvalidArgumentException($optionTrackingDetailsArrayErrorMessage, __LINE__); |
||
291 | } |
||
292 | // validation for constraint: maxOccurs(10) |
||
293 | if (is_array($optionTrackingDetails) && count($optionTrackingDetails) > 10) { |
||
294 | 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__); |
||
295 | } |
||
296 | $this->OptionTrackingDetails = $optionTrackingDetails; |
||
297 | return $this; |
||
298 | } |
||
299 | /** |
||
300 | * Add item to OptionTrackingDetails value |
||
301 | * @throws \InvalidArgumentException |
||
302 | * @param \PayPal\StructType\OptionTrackingDetailsType $item |
||
303 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
304 | */ |
||
305 | public function addToOptionTrackingDetails(\PayPal\StructType\OptionTrackingDetailsType $item) |
||
306 | { |
||
307 | // validation for constraint: itemType |
||
308 | if (!$item instanceof \PayPal\StructType\OptionTrackingDetailsType) { |
||
309 | throw new \InvalidArgumentException(sprintf('The OptionTrackingDetails property can only contain items of type \PayPal\StructType\OptionTrackingDetailsType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
310 | } |
||
311 | // validation for constraint: maxOccurs(10) |
||
312 | if (is_array($this->OptionTrackingDetails) && count($this->OptionTrackingDetails) >= 10) { |
||
313 | 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 10', count($this->OptionTrackingDetails)), __LINE__); |
||
314 | } |
||
315 | $this->OptionTrackingDetails[] = $item; |
||
316 | return $this; |
||
317 | } |
||
318 | /** |
||
319 | * Get SoldoutURL value |
||
320 | * @return string|null |
||
321 | */ |
||
322 | public function getSoldoutURL() |
||
325 | } |
||
326 | /** |
||
327 | * Set SoldoutURL value |
||
328 | * @param string $soldoutURL |
||
329 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
330 | */ |
||
331 | public function setSoldoutURL($soldoutURL = null) |
||
332 | { |
||
333 | // validation for constraint: string |
||
334 | if (!is_null($soldoutURL) && !is_string($soldoutURL)) { |
||
335 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($soldoutURL, true), gettype($soldoutURL)), __LINE__); |
||
336 | } |
||
337 | $this->SoldoutURL = $soldoutURL; |
||
338 | return $this; |
||
339 | } |
||
340 | /** |
||
341 | * Get DigitalDownloadKeys value |
||
342 | * @return string[]|null |
||
343 | */ |
||
344 | public function getDigitalDownloadKeys() |
||
345 | { |
||
346 | return $this->DigitalDownloadKeys; |
||
347 | } |
||
348 | /** |
||
349 | * This method is responsible for validating the values passed to the setDigitalDownloadKeys method |
||
350 | * This method is willingly generated in order to preserve the one-line inline validation within the setDigitalDownloadKeys method |
||
351 | * @param array $values |
||
352 | * @return string A non-empty message if the values does not match the validation rules |
||
353 | */ |
||
354 | public static function validateDigitalDownloadKeysForArrayConstraintsFromSetDigitalDownloadKeys(array $values = array()) |
||
369 | } |
||
370 | /** |
||
371 | * Set DigitalDownloadKeys value |
||
372 | * @throws \InvalidArgumentException |
||
373 | * @param string[] $digitalDownloadKeys |
||
374 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
375 | */ |
||
376 | public function setDigitalDownloadKeys(array $digitalDownloadKeys = array()) |
||
388 | } |
||
389 | /** |
||
390 | * Add item to DigitalDownloadKeys value |
||
391 | * @throws \InvalidArgumentException |
||
392 | * @param string $item |
||
393 | * @return \PayPal\StructType\BMGetInventoryResponseType |
||
394 | */ |
||
395 | public function addToDigitalDownloadKeys($item) |
||
407 | } |
||
408 | } |
||
409 |