| Total Complexity | 107 |
| Total Lines | 706 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like BMGetButtonDetailsResponseType 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 BMGetButtonDetailsResponseType, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 12 | class BMGetButtonDetailsResponseType extends AbstractResponseType |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * The Website |
||
| 16 | * Meta information extracted from the WSDL |
||
| 17 | * - maxOccurs: 1 |
||
| 18 | * - minOccurs: 0 |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | public $Website; |
||
| 22 | /** |
||
| 23 | * The Email |
||
| 24 | * Meta information extracted from the WSDL |
||
| 25 | * - maxOccurs: 1 |
||
| 26 | * - minOccurs: 0 |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | public $Email; |
||
| 30 | /** |
||
| 31 | * The Mobile |
||
| 32 | * Meta information extracted from the WSDL |
||
| 33 | * - maxOccurs: 1 |
||
| 34 | * - minOccurs: 0 |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | public $Mobile; |
||
| 38 | /** |
||
| 39 | * The HostedButtonID |
||
| 40 | * Meta information extracted from the WSDL |
||
| 41 | * - maxOccurs: 1 |
||
| 42 | * - minOccurs: 0 |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | public $HostedButtonID; |
||
| 46 | /** |
||
| 47 | * The ButtonType |
||
| 48 | * Meta information extracted from the WSDL |
||
| 49 | * - documentation: Type of button. One of the following: BUYNOW, CART, GIFTCERTIFICATE. SUBSCRIBE, PAYMENTPLAN, AUTOBILLING, DONATE, VIEWCART or UNSUBSCRIBE |
||
| 50 | * - maxOccurs: 1 |
||
| 51 | * - minOccurs: 0 |
||
| 52 | * @var string |
||
| 53 | */ |
||
| 54 | public $ButtonType; |
||
| 55 | /** |
||
| 56 | * The ButtonCode |
||
| 57 | * Meta information extracted from the WSDL |
||
| 58 | * - documentation: Type of button code. One of the following: hosted, encrypted or cleartext |
||
| 59 | * - maxOccurs: 1 |
||
| 60 | * - minOccurs: 0 |
||
| 61 | * @var string |
||
| 62 | */ |
||
| 63 | public $ButtonCode; |
||
| 64 | /** |
||
| 65 | * The ButtonSubType |
||
| 66 | * Meta information extracted from the WSDL |
||
| 67 | * - documentation: Button sub type. optional for button types buynow and cart only Either PRODUCTS or SERVICES |
||
| 68 | * - maxOccurs: 1 |
||
| 69 | * - minOccurs: 0 |
||
| 70 | * @var string |
||
| 71 | */ |
||
| 72 | public $ButtonSubType; |
||
| 73 | /** |
||
| 74 | * The ButtonVar |
||
| 75 | * Meta information extracted from the WSDL |
||
| 76 | * - documentation: Button Variable information Character length and limitations: 63 single-byte alphanumeric characters |
||
| 77 | * - maxOccurs: 1000 |
||
| 78 | * - minOccurs: 0 |
||
| 79 | * @var string[] |
||
| 80 | */ |
||
| 81 | public $ButtonVar; |
||
| 82 | /** |
||
| 83 | * The OptionDetails |
||
| 84 | * Meta information extracted from the WSDL |
||
| 85 | * - maxOccurs: 5 |
||
| 86 | * - minOccurs: 0 |
||
| 87 | * @var \PayPal\StructType\OptionDetailsType[] |
||
| 88 | */ |
||
| 89 | public $OptionDetails; |
||
| 90 | /** |
||
| 91 | * The TextBox |
||
| 92 | * Meta information extracted from the WSDL |
||
| 93 | * - documentation: Text field |
||
| 94 | * - maxOccurs: 2 |
||
| 95 | * - minOccurs: 0 |
||
| 96 | * @var string[] |
||
| 97 | */ |
||
| 98 | public $TextBox; |
||
| 99 | /** |
||
| 100 | * The ButtonImage |
||
| 101 | * Meta information extracted from the WSDL |
||
| 102 | * - documentation: Button image to use. One of: REG, SML, or CC |
||
| 103 | * - maxOccurs: 1 |
||
| 104 | * - minOccurs: 0 |
||
| 105 | * @var string |
||
| 106 | */ |
||
| 107 | public $ButtonImage; |
||
| 108 | /** |
||
| 109 | * The ButtonImageURL |
||
| 110 | * Meta information extracted from the WSDL |
||
| 111 | * - documentation: Button URL for custom button image. |
||
| 112 | * - maxOccurs: 1 |
||
| 113 | * - minOccurs: 0 |
||
| 114 | * @var string |
||
| 115 | */ |
||
| 116 | public $ButtonImageURL; |
||
| 117 | /** |
||
| 118 | * The BuyNowText |
||
| 119 | * Meta information extracted from the WSDL |
||
| 120 | * - documentation: Text to use on Buy Now Button. Either BUYNOW or PAYNOW |
||
| 121 | * - maxOccurs: 1 |
||
| 122 | * - minOccurs: 0 |
||
| 123 | * @var string |
||
| 124 | */ |
||
| 125 | public $BuyNowText; |
||
| 126 | /** |
||
| 127 | * The SubscribeText |
||
| 128 | * Meta information extracted from the WSDL |
||
| 129 | * - documentation: Text to use on Subscribe button. Must be either BUYNOW or SUBSCRIBE |
||
| 130 | * - maxOccurs: 1 |
||
| 131 | * - minOccurs: 0 |
||
| 132 | * @var string |
||
| 133 | */ |
||
| 134 | public $SubscribeText; |
||
| 135 | /** |
||
| 136 | * The ButtonCountry |
||
| 137 | * Meta information extracted from the WSDL |
||
| 138 | * - documentation: Button Country. Valid ISO country code or 'International' |
||
| 139 | * - maxOccurs: 1 |
||
| 140 | * - minOccurs: 0 |
||
| 141 | * @var string |
||
| 142 | */ |
||
| 143 | public $ButtonCountry; |
||
| 144 | /** |
||
| 145 | * The ButtonLanguage |
||
| 146 | * Meta information extracted from the WSDL |
||
| 147 | * - documentation: Button language code. Character length and limitations: 3 single-byte alphanumeric characters |
||
| 148 | * - maxOccurs: 1 |
||
| 149 | * - minOccurs: 0 |
||
| 150 | * @var string |
||
| 151 | */ |
||
| 152 | public $ButtonLanguage; |
||
| 153 | /** |
||
| 154 | * Constructor method for BMGetButtonDetailsResponseType |
||
| 155 | * @uses BMGetButtonDetailsResponseType::setWebsite() |
||
| 156 | * @uses BMGetButtonDetailsResponseType::setEmail() |
||
| 157 | * @uses BMGetButtonDetailsResponseType::setMobile() |
||
| 158 | * @uses BMGetButtonDetailsResponseType::setHostedButtonID() |
||
| 159 | * @uses BMGetButtonDetailsResponseType::setButtonType() |
||
| 160 | * @uses BMGetButtonDetailsResponseType::setButtonCode() |
||
| 161 | * @uses BMGetButtonDetailsResponseType::setButtonSubType() |
||
| 162 | * @uses BMGetButtonDetailsResponseType::setButtonVar() |
||
| 163 | * @uses BMGetButtonDetailsResponseType::setOptionDetails() |
||
| 164 | * @uses BMGetButtonDetailsResponseType::setTextBox() |
||
| 165 | * @uses BMGetButtonDetailsResponseType::setButtonImage() |
||
| 166 | * @uses BMGetButtonDetailsResponseType::setButtonImageURL() |
||
| 167 | * @uses BMGetButtonDetailsResponseType::setBuyNowText() |
||
| 168 | * @uses BMGetButtonDetailsResponseType::setSubscribeText() |
||
| 169 | * @uses BMGetButtonDetailsResponseType::setButtonCountry() |
||
| 170 | * @uses BMGetButtonDetailsResponseType::setButtonLanguage() |
||
| 171 | * @param string $website |
||
| 172 | * @param string $email |
||
| 173 | * @param string $mobile |
||
| 174 | * @param string $hostedButtonID |
||
| 175 | * @param string $buttonType |
||
| 176 | * @param string $buttonCode |
||
| 177 | * @param string $buttonSubType |
||
| 178 | * @param string[] $buttonVar |
||
| 179 | * @param \PayPal\StructType\OptionDetailsType[] $optionDetails |
||
| 180 | * @param string[] $textBox |
||
| 181 | * @param string $buttonImage |
||
| 182 | * @param string $buttonImageURL |
||
| 183 | * @param string $buyNowText |
||
| 184 | * @param string $subscribeText |
||
| 185 | * @param string $buttonCountry |
||
| 186 | * @param string $buttonLanguage |
||
| 187 | */ |
||
| 188 | public function __construct($website = null, $email = null, $mobile = null, $hostedButtonID = null, $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) |
||
| 189 | { |
||
| 190 | $this |
||
| 191 | ->setWebsite($website) |
||
| 192 | ->setEmail($email) |
||
| 193 | ->setMobile($mobile) |
||
| 194 | ->setHostedButtonID($hostedButtonID) |
||
| 195 | ->setButtonType($buttonType) |
||
| 196 | ->setButtonCode($buttonCode) |
||
| 197 | ->setButtonSubType($buttonSubType) |
||
| 198 | ->setButtonVar($buttonVar) |
||
| 199 | ->setOptionDetails($optionDetails) |
||
| 200 | ->setTextBox($textBox) |
||
| 201 | ->setButtonImage($buttonImage) |
||
| 202 | ->setButtonImageURL($buttonImageURL) |
||
| 203 | ->setBuyNowText($buyNowText) |
||
| 204 | ->setSubscribeText($subscribeText) |
||
| 205 | ->setButtonCountry($buttonCountry) |
||
| 206 | ->setButtonLanguage($buttonLanguage); |
||
| 207 | } |
||
| 208 | /** |
||
| 209 | * Get Website value |
||
| 210 | * @return string|null |
||
| 211 | */ |
||
| 212 | public function getWebsite() |
||
| 213 | { |
||
| 214 | return $this->Website; |
||
| 215 | } |
||
| 216 | /** |
||
| 217 | * Set Website value |
||
| 218 | * @param string $website |
||
| 219 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 220 | */ |
||
| 221 | public function setWebsite($website = null) |
||
| 222 | { |
||
| 223 | // validation for constraint: string |
||
| 224 | if (!is_null($website) && !is_string($website)) { |
||
|
|
|||
| 225 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($website, true), gettype($website)), __LINE__); |
||
| 226 | } |
||
| 227 | $this->Website = $website; |
||
| 228 | return $this; |
||
| 229 | } |
||
| 230 | /** |
||
| 231 | * Get Email value |
||
| 232 | * @return string|null |
||
| 233 | */ |
||
| 234 | public function getEmail() |
||
| 235 | { |
||
| 236 | return $this->Email; |
||
| 237 | } |
||
| 238 | /** |
||
| 239 | * Set Email value |
||
| 240 | * @param string $email |
||
| 241 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 242 | */ |
||
| 243 | public function setEmail($email = null) |
||
| 244 | { |
||
| 245 | // validation for constraint: string |
||
| 246 | if (!is_null($email) && !is_string($email)) { |
||
| 247 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($email, true), gettype($email)), __LINE__); |
||
| 248 | } |
||
| 249 | $this->Email = $email; |
||
| 250 | return $this; |
||
| 251 | } |
||
| 252 | /** |
||
| 253 | * Get Mobile value |
||
| 254 | * @return string|null |
||
| 255 | */ |
||
| 256 | public function getMobile() |
||
| 257 | { |
||
| 258 | return $this->Mobile; |
||
| 259 | } |
||
| 260 | /** |
||
| 261 | * Set Mobile value |
||
| 262 | * @param string $mobile |
||
| 263 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 264 | */ |
||
| 265 | public function setMobile($mobile = null) |
||
| 273 | } |
||
| 274 | /** |
||
| 275 | * Get HostedButtonID value |
||
| 276 | * @return string|null |
||
| 277 | */ |
||
| 278 | public function getHostedButtonID() |
||
| 279 | { |
||
| 280 | return $this->HostedButtonID; |
||
| 281 | } |
||
| 282 | /** |
||
| 283 | * Set HostedButtonID value |
||
| 284 | * @param string $hostedButtonID |
||
| 285 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 286 | */ |
||
| 287 | public function setHostedButtonID($hostedButtonID = null) |
||
| 288 | { |
||
| 289 | // validation for constraint: string |
||
| 290 | if (!is_null($hostedButtonID) && !is_string($hostedButtonID)) { |
||
| 291 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($hostedButtonID, true), gettype($hostedButtonID)), __LINE__); |
||
| 292 | } |
||
| 293 | $this->HostedButtonID = $hostedButtonID; |
||
| 294 | return $this; |
||
| 295 | } |
||
| 296 | /** |
||
| 297 | * Get ButtonType value |
||
| 298 | * @return string|null |
||
| 299 | */ |
||
| 300 | public function getButtonType() |
||
| 301 | { |
||
| 302 | return $this->ButtonType; |
||
| 303 | } |
||
| 304 | /** |
||
| 305 | * Set ButtonType value |
||
| 306 | * @uses \PayPal\EnumType\ButtonTypeType::valueIsValid() |
||
| 307 | * @uses \PayPal\EnumType\ButtonTypeType::getValidValues() |
||
| 308 | * @throws \InvalidArgumentException |
||
| 309 | * @param string $buttonType |
||
| 310 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 311 | */ |
||
| 312 | public function setButtonType($buttonType = null) |
||
| 313 | { |
||
| 314 | // validation for constraint: enumeration |
||
| 315 | if (!\PayPal\EnumType\ButtonTypeType::valueIsValid($buttonType)) { |
||
| 316 | throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \PayPal\EnumType\ButtonTypeType', is_array($buttonType) ? implode(', ', $buttonType) : var_export($buttonType, true), implode(', ', \PayPal\EnumType\ButtonTypeType::getValidValues())), __LINE__); |
||
| 317 | } |
||
| 318 | $this->ButtonType = $buttonType; |
||
| 319 | return $this; |
||
| 320 | } |
||
| 321 | /** |
||
| 322 | * Get ButtonCode value |
||
| 323 | * @return string|null |
||
| 324 | */ |
||
| 325 | public function getButtonCode() |
||
| 326 | { |
||
| 327 | return $this->ButtonCode; |
||
| 328 | } |
||
| 329 | /** |
||
| 330 | * Set ButtonCode value |
||
| 331 | * @uses \PayPal\EnumType\ButtonCodeType::valueIsValid() |
||
| 332 | * @uses \PayPal\EnumType\ButtonCodeType::getValidValues() |
||
| 333 | * @throws \InvalidArgumentException |
||
| 334 | * @param string $buttonCode |
||
| 335 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 336 | */ |
||
| 337 | public function setButtonCode($buttonCode = null) |
||
| 338 | { |
||
| 339 | // validation for constraint: enumeration |
||
| 340 | if (!\PayPal\EnumType\ButtonCodeType::valueIsValid($buttonCode)) { |
||
| 341 | throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \PayPal\EnumType\ButtonCodeType', is_array($buttonCode) ? implode(', ', $buttonCode) : var_export($buttonCode, true), implode(', ', \PayPal\EnumType\ButtonCodeType::getValidValues())), __LINE__); |
||
| 342 | } |
||
| 343 | $this->ButtonCode = $buttonCode; |
||
| 344 | return $this; |
||
| 345 | } |
||
| 346 | /** |
||
| 347 | * Get ButtonSubType value |
||
| 348 | * @return string|null |
||
| 349 | */ |
||
| 350 | public function getButtonSubType() |
||
| 351 | { |
||
| 352 | return $this->ButtonSubType; |
||
| 353 | } |
||
| 354 | /** |
||
| 355 | * Set ButtonSubType value |
||
| 356 | * @uses \PayPal\EnumType\ButtonSubTypeType::valueIsValid() |
||
| 357 | * @uses \PayPal\EnumType\ButtonSubTypeType::getValidValues() |
||
| 358 | * @throws \InvalidArgumentException |
||
| 359 | * @param string $buttonSubType |
||
| 360 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 361 | */ |
||
| 362 | public function setButtonSubType($buttonSubType = null) |
||
| 363 | { |
||
| 364 | // validation for constraint: enumeration |
||
| 365 | if (!\PayPal\EnumType\ButtonSubTypeType::valueIsValid($buttonSubType)) { |
||
| 366 | throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \PayPal\EnumType\ButtonSubTypeType', is_array($buttonSubType) ? implode(', ', $buttonSubType) : var_export($buttonSubType, true), implode(', ', \PayPal\EnumType\ButtonSubTypeType::getValidValues())), __LINE__); |
||
| 367 | } |
||
| 368 | $this->ButtonSubType = $buttonSubType; |
||
| 369 | return $this; |
||
| 370 | } |
||
| 371 | /** |
||
| 372 | * Get ButtonVar value |
||
| 373 | * @return string[]|null |
||
| 374 | */ |
||
| 375 | public function getButtonVar() |
||
| 376 | { |
||
| 377 | return $this->ButtonVar; |
||
| 378 | } |
||
| 379 | /** |
||
| 380 | * This method is responsible for validating the values passed to the setButtonVar method |
||
| 381 | * This method is willingly generated in order to preserve the one-line inline validation within the setButtonVar method |
||
| 382 | * @param array $values |
||
| 383 | * @return string A non-empty message if the values does not match the validation rules |
||
| 384 | */ |
||
| 385 | public static function validateButtonVarForArrayConstraintsFromSetButtonVar(array $values = array()) |
||
| 386 | { |
||
| 387 | $message = ''; |
||
| 388 | $invalidValues = []; |
||
| 389 | foreach ($values as $bMGetButtonDetailsResponseTypeButtonVarItem) { |
||
| 390 | // validation for constraint: itemType |
||
| 391 | if (!is_string($bMGetButtonDetailsResponseTypeButtonVarItem)) { |
||
| 392 | $invalidValues[] = is_object($bMGetButtonDetailsResponseTypeButtonVarItem) ? get_class($bMGetButtonDetailsResponseTypeButtonVarItem) : sprintf('%s(%s)', gettype($bMGetButtonDetailsResponseTypeButtonVarItem), var_export($bMGetButtonDetailsResponseTypeButtonVarItem, true)); |
||
| 393 | } |
||
| 394 | } |
||
| 395 | if (!empty($invalidValues)) { |
||
| 396 | $message = sprintf('The ButtonVar property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
| 397 | } |
||
| 398 | unset($invalidValues); |
||
| 399 | return $message; |
||
| 400 | } |
||
| 401 | /** |
||
| 402 | * Set ButtonVar value |
||
| 403 | * @throws \InvalidArgumentException |
||
| 404 | * @param string[] $buttonVar |
||
| 405 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 406 | */ |
||
| 407 | public function setButtonVar(array $buttonVar = array()) |
||
| 408 | { |
||
| 409 | // validation for constraint: array |
||
| 410 | if ('' !== ($buttonVarArrayErrorMessage = self::validateButtonVarForArrayConstraintsFromSetButtonVar($buttonVar))) { |
||
| 411 | throw new \InvalidArgumentException($buttonVarArrayErrorMessage, __LINE__); |
||
| 412 | } |
||
| 413 | // validation for constraint: maxOccurs(1000) |
||
| 414 | if (is_array($buttonVar) && count($buttonVar) > 1000) { |
||
| 415 | 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($buttonVar)), __LINE__); |
||
| 416 | } |
||
| 417 | $this->ButtonVar = $buttonVar; |
||
| 418 | return $this; |
||
| 419 | } |
||
| 420 | /** |
||
| 421 | * Add item to ButtonVar value |
||
| 422 | * @throws \InvalidArgumentException |
||
| 423 | * @param string $item |
||
| 424 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 425 | */ |
||
| 426 | public function addToButtonVar($item) |
||
| 427 | { |
||
| 428 | // validation for constraint: itemType |
||
| 429 | if (!is_string($item)) { |
||
| 430 | throw new \InvalidArgumentException(sprintf('The ButtonVar property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
| 431 | } |
||
| 432 | // validation for constraint: maxOccurs(1000) |
||
| 433 | if (is_array($this->ButtonVar) && count($this->ButtonVar) >= 1000) { |
||
| 434 | 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->ButtonVar)), __LINE__); |
||
| 435 | } |
||
| 436 | $this->ButtonVar[] = $item; |
||
| 437 | return $this; |
||
| 438 | } |
||
| 439 | /** |
||
| 440 | * Get OptionDetails value |
||
| 441 | * @return \PayPal\StructType\OptionDetailsType[]|null |
||
| 442 | */ |
||
| 443 | public function getOptionDetails() |
||
| 444 | { |
||
| 445 | return $this->OptionDetails; |
||
| 446 | } |
||
| 447 | /** |
||
| 448 | * This method is responsible for validating the values passed to the setOptionDetails method |
||
| 449 | * This method is willingly generated in order to preserve the one-line inline validation within the setOptionDetails method |
||
| 450 | * @param array $values |
||
| 451 | * @return string A non-empty message if the values does not match the validation rules |
||
| 452 | */ |
||
| 453 | public static function validateOptionDetailsForArrayConstraintsFromSetOptionDetails(array $values = array()) |
||
| 454 | { |
||
| 455 | $message = ''; |
||
| 456 | $invalidValues = []; |
||
| 457 | foreach ($values as $bMGetButtonDetailsResponseTypeOptionDetailsItem) { |
||
| 458 | // validation for constraint: itemType |
||
| 459 | if (!$bMGetButtonDetailsResponseTypeOptionDetailsItem instanceof \PayPal\StructType\OptionDetailsType) { |
||
| 460 | $invalidValues[] = is_object($bMGetButtonDetailsResponseTypeOptionDetailsItem) ? get_class($bMGetButtonDetailsResponseTypeOptionDetailsItem) : sprintf('%s(%s)', gettype($bMGetButtonDetailsResponseTypeOptionDetailsItem), var_export($bMGetButtonDetailsResponseTypeOptionDetailsItem, true)); |
||
| 461 | } |
||
| 462 | } |
||
| 463 | if (!empty($invalidValues)) { |
||
| 464 | $message = sprintf('The OptionDetails property can only contain items of type \PayPal\StructType\OptionDetailsType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
| 465 | } |
||
| 466 | unset($invalidValues); |
||
| 467 | return $message; |
||
| 468 | } |
||
| 469 | /** |
||
| 470 | * Set OptionDetails value |
||
| 471 | * @throws \InvalidArgumentException |
||
| 472 | * @param \PayPal\StructType\OptionDetailsType[] $optionDetails |
||
| 473 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 474 | */ |
||
| 475 | public function setOptionDetails(array $optionDetails = array()) |
||
| 476 | { |
||
| 477 | // validation for constraint: array |
||
| 478 | if ('' !== ($optionDetailsArrayErrorMessage = self::validateOptionDetailsForArrayConstraintsFromSetOptionDetails($optionDetails))) { |
||
| 479 | throw new \InvalidArgumentException($optionDetailsArrayErrorMessage, __LINE__); |
||
| 480 | } |
||
| 481 | // validation for constraint: maxOccurs(5) |
||
| 482 | if (is_array($optionDetails) && count($optionDetails) > 5) { |
||
| 483 | throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 5', count($optionDetails)), __LINE__); |
||
| 484 | } |
||
| 485 | $this->OptionDetails = $optionDetails; |
||
| 486 | return $this; |
||
| 487 | } |
||
| 488 | /** |
||
| 489 | * Add item to OptionDetails value |
||
| 490 | * @throws \InvalidArgumentException |
||
| 491 | * @param \PayPal\StructType\OptionDetailsType $item |
||
| 492 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 493 | */ |
||
| 494 | public function addToOptionDetails(\PayPal\StructType\OptionDetailsType $item) |
||
| 495 | { |
||
| 496 | // validation for constraint: itemType |
||
| 497 | if (!$item instanceof \PayPal\StructType\OptionDetailsType) { |
||
| 498 | throw new \InvalidArgumentException(sprintf('The OptionDetails property can only contain items of type \PayPal\StructType\OptionDetailsType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
| 499 | } |
||
| 500 | // validation for constraint: maxOccurs(5) |
||
| 501 | if (is_array($this->OptionDetails) && count($this->OptionDetails) >= 5) { |
||
| 502 | 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 5', count($this->OptionDetails)), __LINE__); |
||
| 503 | } |
||
| 504 | $this->OptionDetails[] = $item; |
||
| 505 | return $this; |
||
| 506 | } |
||
| 507 | /** |
||
| 508 | * Get TextBox value |
||
| 509 | * @return string[]|null |
||
| 510 | */ |
||
| 511 | public function getTextBox() |
||
| 512 | { |
||
| 513 | return $this->TextBox; |
||
| 514 | } |
||
| 515 | /** |
||
| 516 | * This method is responsible for validating the values passed to the setTextBox method |
||
| 517 | * This method is willingly generated in order to preserve the one-line inline validation within the setTextBox method |
||
| 518 | * @param array $values |
||
| 519 | * @return string A non-empty message if the values does not match the validation rules |
||
| 520 | */ |
||
| 521 | public static function validateTextBoxForArrayConstraintsFromSetTextBox(array $values = array()) |
||
| 522 | { |
||
| 523 | $message = ''; |
||
| 524 | $invalidValues = []; |
||
| 525 | foreach ($values as $bMGetButtonDetailsResponseTypeTextBoxItem) { |
||
| 526 | // validation for constraint: itemType |
||
| 527 | if (!is_string($bMGetButtonDetailsResponseTypeTextBoxItem)) { |
||
| 528 | $invalidValues[] = is_object($bMGetButtonDetailsResponseTypeTextBoxItem) ? get_class($bMGetButtonDetailsResponseTypeTextBoxItem) : sprintf('%s(%s)', gettype($bMGetButtonDetailsResponseTypeTextBoxItem), var_export($bMGetButtonDetailsResponseTypeTextBoxItem, true)); |
||
| 529 | } |
||
| 530 | } |
||
| 531 | if (!empty($invalidValues)) { |
||
| 532 | $message = sprintf('The TextBox property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
| 533 | } |
||
| 534 | unset($invalidValues); |
||
| 535 | return $message; |
||
| 536 | } |
||
| 537 | /** |
||
| 538 | * Set TextBox value |
||
| 539 | * @throws \InvalidArgumentException |
||
| 540 | * @param string[] $textBox |
||
| 541 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 542 | */ |
||
| 543 | public function setTextBox(array $textBox = array()) |
||
| 544 | { |
||
| 545 | // validation for constraint: array |
||
| 546 | if ('' !== ($textBoxArrayErrorMessage = self::validateTextBoxForArrayConstraintsFromSetTextBox($textBox))) { |
||
| 547 | throw new \InvalidArgumentException($textBoxArrayErrorMessage, __LINE__); |
||
| 548 | } |
||
| 549 | // validation for constraint: maxOccurs(2) |
||
| 550 | if (is_array($textBox) && count($textBox) > 2) { |
||
| 551 | throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 2', count($textBox)), __LINE__); |
||
| 552 | } |
||
| 553 | $this->TextBox = $textBox; |
||
| 554 | return $this; |
||
| 555 | } |
||
| 556 | /** |
||
| 557 | * Add item to TextBox value |
||
| 558 | * @throws \InvalidArgumentException |
||
| 559 | * @param string $item |
||
| 560 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 561 | */ |
||
| 562 | public function addToTextBox($item) |
||
| 563 | { |
||
| 564 | // validation for constraint: itemType |
||
| 565 | if (!is_string($item)) { |
||
| 566 | throw new \InvalidArgumentException(sprintf('The TextBox property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
| 567 | } |
||
| 568 | // validation for constraint: maxOccurs(2) |
||
| 569 | if (is_array($this->TextBox) && count($this->TextBox) >= 2) { |
||
| 570 | 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 2', count($this->TextBox)), __LINE__); |
||
| 571 | } |
||
| 572 | $this->TextBox[] = $item; |
||
| 573 | return $this; |
||
| 574 | } |
||
| 575 | /** |
||
| 576 | * Get ButtonImage value |
||
| 577 | * @return string|null |
||
| 578 | */ |
||
| 579 | public function getButtonImage() |
||
| 580 | { |
||
| 581 | return $this->ButtonImage; |
||
| 582 | } |
||
| 583 | /** |
||
| 584 | * Set ButtonImage value |
||
| 585 | * @uses \PayPal\EnumType\ButtonImageType::valueIsValid() |
||
| 586 | * @uses \PayPal\EnumType\ButtonImageType::getValidValues() |
||
| 587 | * @throws \InvalidArgumentException |
||
| 588 | * @param string $buttonImage |
||
| 589 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 590 | */ |
||
| 591 | public function setButtonImage($buttonImage = null) |
||
| 592 | { |
||
| 593 | // validation for constraint: enumeration |
||
| 594 | if (!\PayPal\EnumType\ButtonImageType::valueIsValid($buttonImage)) { |
||
| 595 | throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \PayPal\EnumType\ButtonImageType', is_array($buttonImage) ? implode(', ', $buttonImage) : var_export($buttonImage, true), implode(', ', \PayPal\EnumType\ButtonImageType::getValidValues())), __LINE__); |
||
| 596 | } |
||
| 597 | $this->ButtonImage = $buttonImage; |
||
| 598 | return $this; |
||
| 599 | } |
||
| 600 | /** |
||
| 601 | * Get ButtonImageURL value |
||
| 602 | * @return string|null |
||
| 603 | */ |
||
| 604 | public function getButtonImageURL() |
||
| 605 | { |
||
| 606 | return $this->ButtonImageURL; |
||
| 607 | } |
||
| 608 | /** |
||
| 609 | * Set ButtonImageURL value |
||
| 610 | * @param string $buttonImageURL |
||
| 611 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 612 | */ |
||
| 613 | public function setButtonImageURL($buttonImageURL = null) |
||
| 614 | { |
||
| 615 | // validation for constraint: string |
||
| 616 | if (!is_null($buttonImageURL) && !is_string($buttonImageURL)) { |
||
| 617 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($buttonImageURL, true), gettype($buttonImageURL)), __LINE__); |
||
| 618 | } |
||
| 619 | $this->ButtonImageURL = $buttonImageURL; |
||
| 620 | return $this; |
||
| 621 | } |
||
| 622 | /** |
||
| 623 | * Get BuyNowText value |
||
| 624 | * @return string|null |
||
| 625 | */ |
||
| 626 | public function getBuyNowText() |
||
| 627 | { |
||
| 628 | return $this->BuyNowText; |
||
| 629 | } |
||
| 630 | /** |
||
| 631 | * Set BuyNowText value |
||
| 632 | * @uses \PayPal\EnumType\BuyNowTextType::valueIsValid() |
||
| 633 | * @uses \PayPal\EnumType\BuyNowTextType::getValidValues() |
||
| 634 | * @throws \InvalidArgumentException |
||
| 635 | * @param string $buyNowText |
||
| 636 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 637 | */ |
||
| 638 | public function setBuyNowText($buyNowText = null) |
||
| 639 | { |
||
| 640 | // validation for constraint: enumeration |
||
| 641 | if (!\PayPal\EnumType\BuyNowTextType::valueIsValid($buyNowText)) { |
||
| 642 | throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \PayPal\EnumType\BuyNowTextType', is_array($buyNowText) ? implode(', ', $buyNowText) : var_export($buyNowText, true), implode(', ', \PayPal\EnumType\BuyNowTextType::getValidValues())), __LINE__); |
||
| 643 | } |
||
| 644 | $this->BuyNowText = $buyNowText; |
||
| 645 | return $this; |
||
| 646 | } |
||
| 647 | /** |
||
| 648 | * Get SubscribeText value |
||
| 649 | * @return string|null |
||
| 650 | */ |
||
| 651 | public function getSubscribeText() |
||
| 652 | { |
||
| 653 | return $this->SubscribeText; |
||
| 654 | } |
||
| 655 | /** |
||
| 656 | * Set SubscribeText value |
||
| 657 | * @uses \PayPal\EnumType\SubscribeTextType::valueIsValid() |
||
| 658 | * @uses \PayPal\EnumType\SubscribeTextType::getValidValues() |
||
| 659 | * @throws \InvalidArgumentException |
||
| 660 | * @param string $subscribeText |
||
| 661 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 662 | */ |
||
| 663 | public function setSubscribeText($subscribeText = null) |
||
| 664 | { |
||
| 665 | // validation for constraint: enumeration |
||
| 666 | if (!\PayPal\EnumType\SubscribeTextType::valueIsValid($subscribeText)) { |
||
| 667 | throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \PayPal\EnumType\SubscribeTextType', is_array($subscribeText) ? implode(', ', $subscribeText) : var_export($subscribeText, true), implode(', ', \PayPal\EnumType\SubscribeTextType::getValidValues())), __LINE__); |
||
| 668 | } |
||
| 669 | $this->SubscribeText = $subscribeText; |
||
| 670 | return $this; |
||
| 671 | } |
||
| 672 | /** |
||
| 673 | * Get ButtonCountry value |
||
| 674 | * @return string|null |
||
| 675 | */ |
||
| 676 | public function getButtonCountry() |
||
| 677 | { |
||
| 678 | return $this->ButtonCountry; |
||
| 679 | } |
||
| 680 | /** |
||
| 681 | * Set ButtonCountry value |
||
| 682 | * @uses \PayPal\EnumType\CountryCodeType::valueIsValid() |
||
| 683 | * @uses \PayPal\EnumType\CountryCodeType::getValidValues() |
||
| 684 | * @throws \InvalidArgumentException |
||
| 685 | * @param string $buttonCountry |
||
| 686 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 687 | */ |
||
| 688 | public function setButtonCountry($buttonCountry = null) |
||
| 696 | } |
||
| 697 | /** |
||
| 698 | * Get ButtonLanguage value |
||
| 699 | * @return string|null |
||
| 700 | */ |
||
| 701 | public function getButtonLanguage() |
||
| 702 | { |
||
| 703 | return $this->ButtonLanguage; |
||
| 704 | } |
||
| 705 | /** |
||
| 706 | * Set ButtonLanguage value |
||
| 707 | * @param string $buttonLanguage |
||
| 708 | * @return \PayPal\StructType\BMGetButtonDetailsResponseType |
||
| 709 | */ |
||
| 710 | public function setButtonLanguage($buttonLanguage = null) |
||
| 718 | } |
||
| 719 | } |
||
| 720 |