BMGetInventoryResponseType   F
last analyzed

Complexity

Total Complexity 63

Size/Duplication

Total Lines 395
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 97
dl 0
loc 395
rs 3.36
c 1
b 0
f 0
wmc 63

23 Methods

Rating   Name   Duplication   Size   Complexity  
A getOptionName() 0 3 1
A getOptionIndex() 0 3 1
A getSoldoutURL() 0 3 1
A __construct() 0 12 1
A setOptionName() 0 8 3
B validateDigitalDownloadKeysForArrayConstraintsFromSetDigitalDownloadKeys() 0 15 7
A getTrackPnl() 0 3 1
A getHostedButtonID() 0 3 1
A setTrackInv() 0 8 3
A setOptionTrackingDetails() 0 12 4
A setSoldoutURL() 0 8 3
A getTrackInv() 0 3 1
A getOptionTrackingDetails() 0 3 1
A setDigitalDownloadKeys() 0 12 4
A getItemTrackingDetails() 0 3 1
A addToDigitalDownloadKeys() 0 12 6
A setItemTrackingDetails() 0 4 1
A getDigitalDownloadKeys() 0 3 1
B validateOptionTrackingDetailsForArrayConstraintsFromSetOptionTrackingDetails() 0 15 7
A addToOptionTrackingDetails() 0 12 6
A setHostedButtonID() 0 8 3
A setOptionIndex() 0 8 3
A setTrackPnl() 0 8 3

How to fix   Complexity   

Complex Class

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
2
3
namespace PayPal\StructType;
4
5
use \WsdlToPhp\PackageBase\AbstractStructBase;
6
7
/**
8
 * This class stands for BMGetInventoryResponseType StructType
9
 * @subpackage Structs
10
 * @author WsdlToPhp <[email protected]>
11
 */
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)) {
0 ignored issues
show
introduced by
The condition is_string($hostedButtonID) is always true.
Loading history...
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)) {
0 ignored issues
show
introduced by
The condition is_string($trackInv) is always true.
Loading history...
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)) {
0 ignored issues
show
introduced by
The condition is_string($trackPnl) is always true.
Loading history...
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)) {
0 ignored issues
show
introduced by
The condition is_string($optionIndex) is always true.
Loading history...
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()
233
    {
234
        return $this->OptionName;
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)) {
0 ignored issues
show
introduced by
The condition is_string($optionName) is always true.
Loading history...
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)));
0 ignored issues
show
introduced by
The condition is_array($invalidValues) is always true.
Loading history...
introduced by
The condition is_object($invalidValues) is always false.
Loading history...
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) {
0 ignored issues
show
introduced by
$item is always a sub-type of PayPal\StructType\OptionTrackingDetailsType.
Loading history...
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()
323
    {
324
        return $this->SoldoutURL;
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)) {
0 ignored issues
show
introduced by
The condition is_string($soldoutURL) is always true.
Loading history...
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())
355
    {
356
        $message = '';
357
        $invalidValues = [];
358
        foreach ($values as $bMGetInventoryResponseTypeDigitalDownloadKeysItem) {
359
            // validation for constraint: itemType
360
            if (!is_string($bMGetInventoryResponseTypeDigitalDownloadKeysItem)) {
361
                $invalidValues[] = is_object($bMGetInventoryResponseTypeDigitalDownloadKeysItem) ? get_class($bMGetInventoryResponseTypeDigitalDownloadKeysItem) : sprintf('%s(%s)', gettype($bMGetInventoryResponseTypeDigitalDownloadKeysItem), var_export($bMGetInventoryResponseTypeDigitalDownloadKeysItem, true));
362
            }
363
        }
364
        if (!empty($invalidValues)) {
365
            $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)));
0 ignored issues
show
introduced by
The condition is_array($invalidValues) is always true.
Loading history...
introduced by
The condition is_object($invalidValues) is always false.
Loading history...
366
        }
367
        unset($invalidValues);
368
        return $message;
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())
377
    {
378
        // validation for constraint: array
379
        if ('' !== ($digitalDownloadKeysArrayErrorMessage = self::validateDigitalDownloadKeysForArrayConstraintsFromSetDigitalDownloadKeys($digitalDownloadKeys))) {
380
            throw new \InvalidArgumentException($digitalDownloadKeysArrayErrorMessage, __LINE__);
381
        }
382
        // validation for constraint: maxOccurs(1000)
383
        if (is_array($digitalDownloadKeys) && count($digitalDownloadKeys) > 1000) {
384
            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($digitalDownloadKeys)), __LINE__);
385
        }
386
        $this->DigitalDownloadKeys = $digitalDownloadKeys;
387
        return $this;
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)
396
    {
397
        // validation for constraint: itemType
398
        if (!is_string($item)) {
0 ignored issues
show
introduced by
The condition is_string($item) is always true.
Loading history...
399
            throw new \InvalidArgumentException(sprintf('The DigitalDownloadKeys property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
400
        }
401
        // validation for constraint: maxOccurs(1000)
402
        if (is_array($this->DigitalDownloadKeys) && count($this->DigitalDownloadKeys) >= 1000) {
403
            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->DigitalDownloadKeys)), __LINE__);
404
        }
405
        $this->DigitalDownloadKeys[] = $item;
406
        return $this;
407
    }
408
}
409