BMCreateButtonRequestType   F
last analyzed

Complexity

Total Complexity 56

Size/Duplication

Total Lines 512
Duplicated Lines 0 %

Coupling/Cohesion

Components 12
Dependencies 8

Importance

Changes 0
Metric Value
wmc 56
lcom 12
cbo 8
dl 0
loc 512
rs 1.7647
c 0
b 0
f 0

30 Methods

Rating   Name   Duplication   Size   Complexity  
A getButtonType() 0 4 1
A setButtonType() 0 9 2
A getButtonCode() 0 4 1
A setButtonCode() 0 9 2
A getButtonSubType() 0 4 1
A setButtonSubType() 0 9 2
A getButtonVar() 0 4 1
A setButtonVar() 0 11 4
A addToButtonVar() 0 9 3
A getOptionDetails() 0 4 1
A setOptionDetails() 0 11 4
A addToOptionDetails() 0 9 3
A getTextBox() 0 4 1
A setTextBox() 0 11 4
A addToTextBox() 0 9 3
A getButtonImage() 0 4 1
A setButtonImage() 0 9 2
A getButtonImageURL() 0 4 1
A setButtonImageURL() 0 9 3
A getBuyNowText() 0 4 1
A setBuyNowText() 0 9 2
A getSubscribeText() 0 4 1
A setSubscribeText() 0 9 2
A getButtonCountry() 0 4 1
A setButtonCountry() 0 9 2
A getButtonLanguage() 0 4 1
A setButtonLanguage() 0 9 3
A __set_state() 0 4 1
A __toString() 0 4 1
A __construct() 0 16 1

How to fix   Complexity   

Complex Class

Complex classes like BMCreateButtonRequestType 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

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 BMCreateButtonRequestType, 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 BMCreateButtonRequestType StructType
9
 * @subpackage Structs
10
 * @author WsdlToPhp <[email protected]>
11
 */
12
class BMCreateButtonRequestType extends AbstractRequestType
13
{
14
    /**
15
     * The ButtonType
16
     * Meta informations extracted from the WSDL
17
     * - documentation: Type of Button to create. Required Must be one of the following: BUYNOW, CART, GIFTCERTIFICATE. SUBSCRIBE, PAYMENTPLAN, AUTOBILLING, DONATE, VIEWCART or UNSUBSCRIBE
18
     * - maxOccurs: 1
19
     * - minOccurs: 0
20
     * @var string
21
     */
22
    public $ButtonType;
23
    /**
24
     * The ButtonCode
25
     * Meta informations extracted from the WSDL
26
     * - documentation: button code. optional Must be one of the following: hosted, encrypted or cleartext
27
     * - maxOccurs: 1
28
     * - minOccurs: 0
29
     * @var string
30
     */
31
    public $ButtonCode;
32
    /**
33
     * The ButtonSubType
34
     * Meta informations extracted from the WSDL
35
     * - documentation: Button sub type. optional for button types buynow and cart only Must Be either PRODUCTS or SERVICES
36
     * - maxOccurs: 1
37
     * - minOccurs: 0
38
     * @var string
39
     */
40
    public $ButtonSubType;
41
    /**
42
     * The ButtonVar
43
     * Meta informations extracted from the WSDL
44
     * - documentation: Button Variable information At least one required recurring Character length and limitations: 63 single-byte alphanumeric characters
45
     * - maxOccurs: 1000
46
     * - minOccurs: 0
47
     * @var string[]
48
     */
49
    public $ButtonVar;
50
    /**
51
     * The OptionDetails
52
     * Meta informations extracted from the WSDL
53
     * - maxOccurs: 5
54
     * - minOccurs: 0
55
     * @var \PayPal\StructType\OptionDetailsType[]
56
     */
57
    public $OptionDetails;
58
    /**
59
     * The TextBox
60
     * Meta informations extracted from the WSDL
61
     * - documentation: Details of each option for the button. Optional
62
     * - maxOccurs: 2
63
     * - minOccurs: 0
64
     * @var string[]
65
     */
66
    public $TextBox;
67
    /**
68
     * The ButtonImage
69
     * Meta informations extracted from the WSDL
70
     * - documentation: Button image to use. Optional Must be one of: REG, SML, or CC
71
     * - maxOccurs: 1
72
     * - minOccurs: 0
73
     * @var string
74
     */
75
    public $ButtonImage;
76
    /**
77
     * The ButtonImageURL
78
     * Meta informations extracted from the WSDL
79
     * - documentation: Button URL for custom button image. Optional Character length and limitations: 127 single-byte alphanumeric characters
80
     * - maxOccurs: 1
81
     * - minOccurs: 0
82
     * @var string
83
     */
84
    public $ButtonImageURL;
85
    /**
86
     * The BuyNowText
87
     * Meta informations extracted from the WSDL
88
     * - documentation: Text to use on Buy Now Button. Optional Must be either BUYNOW or PAYNOW
89
     * - maxOccurs: 1
90
     * - minOccurs: 0
91
     * @var string
92
     */
93
    public $BuyNowText;
94
    /**
95
     * The SubscribeText
96
     * Meta informations extracted from the WSDL
97
     * - documentation: Text to use on Subscribe button. Optional Must be either BUYNOW or SUBSCRIBE
98
     * - maxOccurs: 1
99
     * - minOccurs: 0
100
     * @var string
101
     */
102
    public $SubscribeText;
103
    /**
104
     * The ButtonCountry
105
     * Meta informations extracted from the WSDL
106
     * - documentation: Button Country. Optional Must be valid ISO country code
107
     * - maxOccurs: 1
108
     * - minOccurs: 0
109
     * @var string
110
     */
111
    public $ButtonCountry;
112
    /**
113
     * The ButtonLanguage
114
     * Meta informations extracted from the WSDL
115
     * - documentation: Button language code. Optional Character length and limitations: 3 single-byte alphanumeric characters
116
     * - maxOccurs: 1
117
     * - minOccurs: 0
118
     * @var string
119
     */
120
    public $ButtonLanguage;
121
    /**
122
     * Constructor method for BMCreateButtonRequestType
123
     * @uses BMCreateButtonRequestType::setButtonType()
124
     * @uses BMCreateButtonRequestType::setButtonCode()
125
     * @uses BMCreateButtonRequestType::setButtonSubType()
126
     * @uses BMCreateButtonRequestType::setButtonVar()
127
     * @uses BMCreateButtonRequestType::setOptionDetails()
128
     * @uses BMCreateButtonRequestType::setTextBox()
129
     * @uses BMCreateButtonRequestType::setButtonImage()
130
     * @uses BMCreateButtonRequestType::setButtonImageURL()
131
     * @uses BMCreateButtonRequestType::setBuyNowText()
132
     * @uses BMCreateButtonRequestType::setSubscribeText()
133
     * @uses BMCreateButtonRequestType::setButtonCountry()
134
     * @uses BMCreateButtonRequestType::setButtonLanguage()
135
     * @param string $buttonType
136
     * @param string $buttonCode
137
     * @param string $buttonSubType
138
     * @param string[] $buttonVar
139
     * @param \PayPal\StructType\OptionDetailsType[] $optionDetails
140
     * @param string[] $textBox
141
     * @param string $buttonImage
142
     * @param string $buttonImageURL
143
     * @param string $buyNowText
144
     * @param string $subscribeText
145
     * @param string $buttonCountry
146
     * @param string $buttonLanguage
147
     */
148
    public function __construct($buttonType = null, $buttonCode = null, $buttonSubType = null, array $buttonVar = array(), array $optionDetails = array(), array $textBox = array(), $buttonImage = null, $buttonImageURL = null, $buyNowText = null, $subscribeText = null, $buttonCountry = null, $buttonLanguage = null)
149
    {
150
        $this
151
            ->setButtonType($buttonType)
152
            ->setButtonCode($buttonCode)
153
            ->setButtonSubType($buttonSubType)
154
            ->setButtonVar($buttonVar)
155
            ->setOptionDetails($optionDetails)
156
            ->setTextBox($textBox)
157
            ->setButtonImage($buttonImage)
158
            ->setButtonImageURL($buttonImageURL)
159
            ->setBuyNowText($buyNowText)
160
            ->setSubscribeText($subscribeText)
161
            ->setButtonCountry($buttonCountry)
162
            ->setButtonLanguage($buttonLanguage);
163
    }
164
    /**
165
     * Get ButtonType value
166
     * @return string|null
167
     */
168
    public function getButtonType()
169
    {
170
        return $this->ButtonType;
171
    }
172
    /**
173
     * Set ButtonType value
174
     * @uses \PayPal\EnumType\ButtonTypeType::valueIsValid()
175
     * @uses \PayPal\EnumType\ButtonTypeType::getValidValues()
176
     * @throws \InvalidArgumentException
177
     * @param string $buttonType
178
     * @return \PayPal\StructType\BMCreateButtonRequestType
179
     */
180
    public function setButtonType($buttonType = null)
181
    {
182
        // validation for constraint: enumeration
183
        if (!\PayPal\EnumType\ButtonTypeType::valueIsValid($buttonType)) {
184
            throw new \InvalidArgumentException(sprintf('Value "%s" is invalid, please use one of: %s', $buttonType, implode(', ', \PayPal\EnumType\ButtonTypeType::getValidValues())), __LINE__);
185
        }
186
        $this->ButtonType = $buttonType;
187
        return $this;
188
    }
189
    /**
190
     * Get ButtonCode value
191
     * @return string|null
192
     */
193
    public function getButtonCode()
194
    {
195
        return $this->ButtonCode;
196
    }
197
    /**
198
     * Set ButtonCode value
199
     * @uses \PayPal\EnumType\ButtonCodeType::valueIsValid()
200
     * @uses \PayPal\EnumType\ButtonCodeType::getValidValues()
201
     * @throws \InvalidArgumentException
202
     * @param string $buttonCode
203
     * @return \PayPal\StructType\BMCreateButtonRequestType
204
     */
205
    public function setButtonCode($buttonCode = null)
206
    {
207
        // validation for constraint: enumeration
208
        if (!\PayPal\EnumType\ButtonCodeType::valueIsValid($buttonCode)) {
209
            throw new \InvalidArgumentException(sprintf('Value "%s" is invalid, please use one of: %s', $buttonCode, implode(', ', \PayPal\EnumType\ButtonCodeType::getValidValues())), __LINE__);
210
        }
211
        $this->ButtonCode = $buttonCode;
212
        return $this;
213
    }
214
    /**
215
     * Get ButtonSubType value
216
     * @return string|null
217
     */
218
    public function getButtonSubType()
219
    {
220
        return $this->ButtonSubType;
221
    }
222
    /**
223
     * Set ButtonSubType value
224
     * @uses \PayPal\EnumType\ButtonSubTypeType::valueIsValid()
225
     * @uses \PayPal\EnumType\ButtonSubTypeType::getValidValues()
226
     * @throws \InvalidArgumentException
227
     * @param string $buttonSubType
228
     * @return \PayPal\StructType\BMCreateButtonRequestType
229
     */
230
    public function setButtonSubType($buttonSubType = null)
231
    {
232
        // validation for constraint: enumeration
233
        if (!\PayPal\EnumType\ButtonSubTypeType::valueIsValid($buttonSubType)) {
234
            throw new \InvalidArgumentException(sprintf('Value "%s" is invalid, please use one of: %s', $buttonSubType, implode(', ', \PayPal\EnumType\ButtonSubTypeType::getValidValues())), __LINE__);
235
        }
236
        $this->ButtonSubType = $buttonSubType;
237
        return $this;
238
    }
239
    /**
240
     * Get ButtonVar value
241
     * @return string[]|null
242
     */
243
    public function getButtonVar()
244
    {
245
        return $this->ButtonVar;
246
    }
247
    /**
248
     * Set ButtonVar value
249
     * @throws \InvalidArgumentException
250
     * @param string[] $buttonVar
251
     * @return \PayPal\StructType\BMCreateButtonRequestType
252
     */
253
    public function setButtonVar(array $buttonVar = array())
254
    {
255
        foreach ($buttonVar as $bMCreateButtonRequestTypeButtonVarItem) {
256
            // validation for constraint: itemType
257
            if (!is_string($bMCreateButtonRequestTypeButtonVarItem)) {
258
                throw new \InvalidArgumentException(sprintf('The ButtonVar property can only contain items of string, "%s" given', is_object($bMCreateButtonRequestTypeButtonVarItem) ? get_class($bMCreateButtonRequestTypeButtonVarItem) : gettype($bMCreateButtonRequestTypeButtonVarItem)), __LINE__);
259
            }
260
        }
261
        $this->ButtonVar = $buttonVar;
262
        return $this;
263
    }
264
    /**
265
     * Add item to ButtonVar value
266
     * @throws \InvalidArgumentException
267
     * @param string $item
268
     * @return \PayPal\StructType\BMCreateButtonRequestType
269
     */
270
    public function addToButtonVar($item)
271
    {
272
        // validation for constraint: itemType
273
        if (!is_string($item)) {
274
            throw new \InvalidArgumentException(sprintf('The ButtonVar property can only contain items of string, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
275
        }
276
        $this->ButtonVar[] = $item;
277
        return $this;
278
    }
279
    /**
280
     * Get OptionDetails value
281
     * @return \PayPal\StructType\OptionDetailsType[]|null
282
     */
283
    public function getOptionDetails()
284
    {
285
        return $this->OptionDetails;
286
    }
287
    /**
288
     * Set OptionDetails value
289
     * @throws \InvalidArgumentException
290
     * @param \PayPal\StructType\OptionDetailsType[] $optionDetails
291
     * @return \PayPal\StructType\BMCreateButtonRequestType
292
     */
293
    public function setOptionDetails(array $optionDetails = array())
294
    {
295
        foreach ($optionDetails as $bMCreateButtonRequestTypeOptionDetailsItem) {
296
            // validation for constraint: itemType
297
            if (!$bMCreateButtonRequestTypeOptionDetailsItem instanceof \PayPal\StructType\OptionDetailsType) {
298
                throw new \InvalidArgumentException(sprintf('The OptionDetails property can only contain items of \PayPal\StructType\OptionDetailsType, "%s" given', is_object($bMCreateButtonRequestTypeOptionDetailsItem) ? get_class($bMCreateButtonRequestTypeOptionDetailsItem) : gettype($bMCreateButtonRequestTypeOptionDetailsItem)), __LINE__);
299
            }
300
        }
301
        $this->OptionDetails = $optionDetails;
302
        return $this;
303
    }
304
    /**
305
     * Add item to OptionDetails value
306
     * @throws \InvalidArgumentException
307
     * @param \PayPal\StructType\OptionDetailsType $item
308
     * @return \PayPal\StructType\BMCreateButtonRequestType
309
     */
310
    public function addToOptionDetails(\PayPal\StructType\OptionDetailsType $item)
311
    {
312
        // validation for constraint: itemType
313
        if (!$item instanceof \PayPal\StructType\OptionDetailsType) {
314
            throw new \InvalidArgumentException(sprintf('The OptionDetails property can only contain items of \PayPal\StructType\OptionDetailsType, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
315
        }
316
        $this->OptionDetails[] = $item;
317
        return $this;
318
    }
319
    /**
320
     * Get TextBox value
321
     * @return string[]|null
322
     */
323
    public function getTextBox()
324
    {
325
        return $this->TextBox;
326
    }
327
    /**
328
     * Set TextBox value
329
     * @throws \InvalidArgumentException
330
     * @param string[] $textBox
331
     * @return \PayPal\StructType\BMCreateButtonRequestType
332
     */
333
    public function setTextBox(array $textBox = array())
334
    {
335
        foreach ($textBox as $bMCreateButtonRequestTypeTextBoxItem) {
336
            // validation for constraint: itemType
337
            if (!is_string($bMCreateButtonRequestTypeTextBoxItem)) {
338
                throw new \InvalidArgumentException(sprintf('The TextBox property can only contain items of string, "%s" given', is_object($bMCreateButtonRequestTypeTextBoxItem) ? get_class($bMCreateButtonRequestTypeTextBoxItem) : gettype($bMCreateButtonRequestTypeTextBoxItem)), __LINE__);
339
            }
340
        }
341
        $this->TextBox = $textBox;
342
        return $this;
343
    }
344
    /**
345
     * Add item to TextBox value
346
     * @throws \InvalidArgumentException
347
     * @param string $item
348
     * @return \PayPal\StructType\BMCreateButtonRequestType
349
     */
350
    public function addToTextBox($item)
351
    {
352
        // validation for constraint: itemType
353
        if (!is_string($item)) {
354
            throw new \InvalidArgumentException(sprintf('The TextBox property can only contain items of string, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
355
        }
356
        $this->TextBox[] = $item;
357
        return $this;
358
    }
359
    /**
360
     * Get ButtonImage value
361
     * @return string|null
362
     */
363
    public function getButtonImage()
364
    {
365
        return $this->ButtonImage;
366
    }
367
    /**
368
     * Set ButtonImage value
369
     * @uses \PayPal\EnumType\ButtonImageType::valueIsValid()
370
     * @uses \PayPal\EnumType\ButtonImageType::getValidValues()
371
     * @throws \InvalidArgumentException
372
     * @param string $buttonImage
373
     * @return \PayPal\StructType\BMCreateButtonRequestType
374
     */
375
    public function setButtonImage($buttonImage = null)
376
    {
377
        // validation for constraint: enumeration
378
        if (!\PayPal\EnumType\ButtonImageType::valueIsValid($buttonImage)) {
379
            throw new \InvalidArgumentException(sprintf('Value "%s" is invalid, please use one of: %s', $buttonImage, implode(', ', \PayPal\EnumType\ButtonImageType::getValidValues())), __LINE__);
380
        }
381
        $this->ButtonImage = $buttonImage;
382
        return $this;
383
    }
384
    /**
385
     * Get ButtonImageURL value
386
     * @return string|null
387
     */
388
    public function getButtonImageURL()
389
    {
390
        return $this->ButtonImageURL;
391
    }
392
    /**
393
     * Set ButtonImageURL value
394
     * @param string $buttonImageURL
395
     * @return \PayPal\StructType\BMCreateButtonRequestType
396
     */
397
    public function setButtonImageURL($buttonImageURL = null)
398
    {
399
        // validation for constraint: string
400
        if (!is_null($buttonImageURL) && !is_string($buttonImageURL)) {
401
            throw new \InvalidArgumentException(sprintf('Invalid value, please provide a string, "%s" given', gettype($buttonImageURL)), __LINE__);
402
        }
403
        $this->ButtonImageURL = $buttonImageURL;
404
        return $this;
405
    }
406
    /**
407
     * Get BuyNowText value
408
     * @return string|null
409
     */
410
    public function getBuyNowText()
411
    {
412
        return $this->BuyNowText;
413
    }
414
    /**
415
     * Set BuyNowText value
416
     * @uses \PayPal\EnumType\BuyNowTextType::valueIsValid()
417
     * @uses \PayPal\EnumType\BuyNowTextType::getValidValues()
418
     * @throws \InvalidArgumentException
419
     * @param string $buyNowText
420
     * @return \PayPal\StructType\BMCreateButtonRequestType
421
     */
422
    public function setBuyNowText($buyNowText = null)
423
    {
424
        // validation for constraint: enumeration
425
        if (!\PayPal\EnumType\BuyNowTextType::valueIsValid($buyNowText)) {
426
            throw new \InvalidArgumentException(sprintf('Value "%s" is invalid, please use one of: %s', $buyNowText, implode(', ', \PayPal\EnumType\BuyNowTextType::getValidValues())), __LINE__);
427
        }
428
        $this->BuyNowText = $buyNowText;
429
        return $this;
430
    }
431
    /**
432
     * Get SubscribeText value
433
     * @return string|null
434
     */
435
    public function getSubscribeText()
436
    {
437
        return $this->SubscribeText;
438
    }
439
    /**
440
     * Set SubscribeText value
441
     * @uses \PayPal\EnumType\SubscribeTextType::valueIsValid()
442
     * @uses \PayPal\EnumType\SubscribeTextType::getValidValues()
443
     * @throws \InvalidArgumentException
444
     * @param string $subscribeText
445
     * @return \PayPal\StructType\BMCreateButtonRequestType
446
     */
447
    public function setSubscribeText($subscribeText = null)
448
    {
449
        // validation for constraint: enumeration
450
        if (!\PayPal\EnumType\SubscribeTextType::valueIsValid($subscribeText)) {
451
            throw new \InvalidArgumentException(sprintf('Value "%s" is invalid, please use one of: %s', $subscribeText, implode(', ', \PayPal\EnumType\SubscribeTextType::getValidValues())), __LINE__);
452
        }
453
        $this->SubscribeText = $subscribeText;
454
        return $this;
455
    }
456
    /**
457
     * Get ButtonCountry value
458
     * @return string|null
459
     */
460
    public function getButtonCountry()
461
    {
462
        return $this->ButtonCountry;
463
    }
464
    /**
465
     * Set ButtonCountry value
466
     * @uses \PayPal\EnumType\CountryCodeType::valueIsValid()
467
     * @uses \PayPal\EnumType\CountryCodeType::getValidValues()
468
     * @throws \InvalidArgumentException
469
     * @param string $buttonCountry
470
     * @return \PayPal\StructType\BMCreateButtonRequestType
471
     */
472
    public function setButtonCountry($buttonCountry = null)
473
    {
474
        // validation for constraint: enumeration
475
        if (!\PayPal\EnumType\CountryCodeType::valueIsValid($buttonCountry)) {
476
            throw new \InvalidArgumentException(sprintf('Value "%s" is invalid, please use one of: %s', $buttonCountry, implode(', ', \PayPal\EnumType\CountryCodeType::getValidValues())), __LINE__);
477
        }
478
        $this->ButtonCountry = $buttonCountry;
479
        return $this;
480
    }
481
    /**
482
     * Get ButtonLanguage value
483
     * @return string|null
484
     */
485
    public function getButtonLanguage()
486
    {
487
        return $this->ButtonLanguage;
488
    }
489
    /**
490
     * Set ButtonLanguage value
491
     * @param string $buttonLanguage
492
     * @return \PayPal\StructType\BMCreateButtonRequestType
493
     */
494
    public function setButtonLanguage($buttonLanguage = null)
495
    {
496
        // validation for constraint: string
497
        if (!is_null($buttonLanguage) && !is_string($buttonLanguage)) {
498
            throw new \InvalidArgumentException(sprintf('Invalid value, please provide a string, "%s" given', gettype($buttonLanguage)), __LINE__);
499
        }
500
        $this->ButtonLanguage = $buttonLanguage;
501
        return $this;
502
    }
503
    /**
504
     * Method called when an object has been exported with var_export() functions
505
     * It allows to return an object instantiated with the values
506
     * @see AbstractStructBase::__set_state()
507
     * @uses AbstractStructBase::__set_state()
508
     * @param array $array the exported values
509
     * @return \PayPal\StructType\BMCreateButtonRequestType
510
     */
511
    public static function __set_state(array $array)
512
    {
513
        return parent::__set_state($array);
514
    }
515
    /**
516
     * Method returning the class name
517
     * @return string __CLASS__
518
     */
519
    public function __toString()
520
    {
521
        return __CLASS__;
522
    }
523
}
524