1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PayPal\StructType; |
4
|
|
|
|
5
|
|
|
use \WsdlToPhp\PackageBase\AbstractStructBase; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This class stands for OptionSelectionDetailsType StructType |
9
|
|
|
* @subpackage Structs |
10
|
|
|
* @author WsdlToPhp <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class OptionSelectionDetailsType extends AbstractStructBase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* The OptionSelection |
16
|
|
|
* Meta information extracted from the WSDL |
17
|
|
|
* - documentation: Option Selection. Required Character length and limitations: 12 single-byte alphanumeric characters |
18
|
|
|
* - maxOccurs: 1 |
19
|
|
|
* - minOccurs: 1 |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
public $OptionSelection; |
23
|
|
|
/** |
24
|
|
|
* The Price |
25
|
|
|
* Meta information extracted from the WSDL |
26
|
|
|
* - documentation: Option Price. Optional |
27
|
|
|
* - maxOccurs: 1 |
28
|
|
|
* - minOccurs: 0 |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
public $Price; |
32
|
|
|
/** |
33
|
|
|
* The OptionType |
34
|
|
|
* Meta information extracted from the WSDL |
35
|
|
|
* - documentation: Option Type Optional |
36
|
|
|
* - maxOccurs: 1 |
37
|
|
|
* - minOccurs: 0 |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
public $OptionType; |
41
|
|
|
/** |
42
|
|
|
* The PaymentPeriod |
43
|
|
|
* Meta information extracted from the WSDL |
44
|
|
|
* - maxOccurs: 10 |
45
|
|
|
* - minOccurs: 0 |
46
|
|
|
* @var \PayPal\StructType\InstallmentDetailsType[] |
47
|
|
|
*/ |
48
|
|
|
public $PaymentPeriod; |
49
|
|
|
/** |
50
|
|
|
* Constructor method for OptionSelectionDetailsType |
51
|
|
|
* @uses OptionSelectionDetailsType::setOptionSelection() |
52
|
|
|
* @uses OptionSelectionDetailsType::setPrice() |
53
|
|
|
* @uses OptionSelectionDetailsType::setOptionType() |
54
|
|
|
* @uses OptionSelectionDetailsType::setPaymentPeriod() |
55
|
|
|
* @param string $optionSelection |
56
|
|
|
* @param string $price |
57
|
|
|
* @param string $optionType |
58
|
|
|
* @param \PayPal\StructType\InstallmentDetailsType[] $paymentPeriod |
59
|
|
|
*/ |
60
|
|
|
public function __construct($optionSelection = null, $price = null, $optionType = null, array $paymentPeriod = array()) |
61
|
|
|
{ |
62
|
|
|
$this |
63
|
|
|
->setOptionSelection($optionSelection) |
64
|
|
|
->setPrice($price) |
65
|
|
|
->setOptionType($optionType) |
66
|
|
|
->setPaymentPeriod($paymentPeriod); |
67
|
|
|
} |
68
|
|
|
/** |
69
|
|
|
* Get OptionSelection value |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function getOptionSelection() |
73
|
|
|
{ |
74
|
|
|
return $this->OptionSelection; |
75
|
|
|
} |
76
|
|
|
/** |
77
|
|
|
* Set OptionSelection value |
78
|
|
|
* @param string $optionSelection |
79
|
|
|
* @return \PayPal\StructType\OptionSelectionDetailsType |
80
|
|
|
*/ |
81
|
|
|
public function setOptionSelection($optionSelection = null) |
82
|
|
|
{ |
83
|
|
|
// validation for constraint: string |
84
|
|
|
if (!is_null($optionSelection) && !is_string($optionSelection)) { |
|
|
|
|
85
|
|
|
throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($optionSelection, true), gettype($optionSelection)), __LINE__); |
86
|
|
|
} |
87
|
|
|
$this->OptionSelection = $optionSelection; |
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
|
|
/** |
91
|
|
|
* Get Price value |
92
|
|
|
* @return string|null |
93
|
|
|
*/ |
94
|
|
|
public function getPrice() |
95
|
|
|
{ |
96
|
|
|
return $this->Price; |
97
|
|
|
} |
98
|
|
|
/** |
99
|
|
|
* Set Price value |
100
|
|
|
* @param string $price |
101
|
|
|
* @return \PayPal\StructType\OptionSelectionDetailsType |
102
|
|
|
*/ |
103
|
|
|
public function setPrice($price = null) |
104
|
|
|
{ |
105
|
|
|
// validation for constraint: string |
106
|
|
|
if (!is_null($price) && !is_string($price)) { |
|
|
|
|
107
|
|
|
throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($price, true), gettype($price)), __LINE__); |
108
|
|
|
} |
109
|
|
|
$this->Price = $price; |
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
/** |
113
|
|
|
* Get OptionType value |
114
|
|
|
* @return string|null |
115
|
|
|
*/ |
116
|
|
|
public function getOptionType() |
117
|
|
|
{ |
118
|
|
|
return $this->OptionType; |
119
|
|
|
} |
120
|
|
|
/** |
121
|
|
|
* Set OptionType value |
122
|
|
|
* @uses \PayPal\EnumType\OptionTypeListType::valueIsValid() |
123
|
|
|
* @uses \PayPal\EnumType\OptionTypeListType::getValidValues() |
124
|
|
|
* @throws \InvalidArgumentException |
125
|
|
|
* @param string $optionType |
126
|
|
|
* @return \PayPal\StructType\OptionSelectionDetailsType |
127
|
|
|
*/ |
128
|
|
|
public function setOptionType($optionType = null) |
129
|
|
|
{ |
130
|
|
|
// validation for constraint: enumeration |
131
|
|
|
if (!\PayPal\EnumType\OptionTypeListType::valueIsValid($optionType)) { |
132
|
|
|
throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \PayPal\EnumType\OptionTypeListType', is_array($optionType) ? implode(', ', $optionType) : var_export($optionType, true), implode(', ', \PayPal\EnumType\OptionTypeListType::getValidValues())), __LINE__); |
|
|
|
|
133
|
|
|
} |
134
|
|
|
$this->OptionType = $optionType; |
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
/** |
138
|
|
|
* Get PaymentPeriod value |
139
|
|
|
* @return \PayPal\StructType\InstallmentDetailsType[]|null |
140
|
|
|
*/ |
141
|
|
|
public function getPaymentPeriod() |
142
|
|
|
{ |
143
|
|
|
return $this->PaymentPeriod; |
144
|
|
|
} |
145
|
|
|
/** |
146
|
|
|
* This method is responsible for validating the values passed to the setPaymentPeriod method |
147
|
|
|
* This method is willingly generated in order to preserve the one-line inline validation within the setPaymentPeriod method |
148
|
|
|
* @param array $values |
149
|
|
|
* @return string A non-empty message if the values does not match the validation rules |
150
|
|
|
*/ |
151
|
|
|
public static function validatePaymentPeriodForArrayConstraintsFromSetPaymentPeriod(array $values = array()) |
152
|
|
|
{ |
153
|
|
|
$message = ''; |
154
|
|
|
$invalidValues = []; |
155
|
|
|
foreach ($values as $optionSelectionDetailsTypePaymentPeriodItem) { |
156
|
|
|
// validation for constraint: itemType |
157
|
|
|
if (!$optionSelectionDetailsTypePaymentPeriodItem instanceof \PayPal\StructType\InstallmentDetailsType) { |
158
|
|
|
$invalidValues[] = is_object($optionSelectionDetailsTypePaymentPeriodItem) ? get_class($optionSelectionDetailsTypePaymentPeriodItem) : sprintf('%s(%s)', gettype($optionSelectionDetailsTypePaymentPeriodItem), var_export($optionSelectionDetailsTypePaymentPeriodItem, true)); |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
if (!empty($invalidValues)) { |
162
|
|
|
$message = sprintf('The PaymentPeriod property can only contain items of type \PayPal\StructType\InstallmentDetailsType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
|
|
|
|
163
|
|
|
} |
164
|
|
|
unset($invalidValues); |
165
|
|
|
return $message; |
166
|
|
|
} |
167
|
|
|
/** |
168
|
|
|
* Set PaymentPeriod value |
169
|
|
|
* @throws \InvalidArgumentException |
170
|
|
|
* @param \PayPal\StructType\InstallmentDetailsType[] $paymentPeriod |
171
|
|
|
* @return \PayPal\StructType\OptionSelectionDetailsType |
172
|
|
|
*/ |
173
|
|
|
public function setPaymentPeriod(array $paymentPeriod = array()) |
174
|
|
|
{ |
175
|
|
|
// validation for constraint: array |
176
|
|
|
if ('' !== ($paymentPeriodArrayErrorMessage = self::validatePaymentPeriodForArrayConstraintsFromSetPaymentPeriod($paymentPeriod))) { |
177
|
|
|
throw new \InvalidArgumentException($paymentPeriodArrayErrorMessage, __LINE__); |
178
|
|
|
} |
179
|
|
|
// validation for constraint: maxOccurs(10) |
180
|
|
|
if (is_array($paymentPeriod) && count($paymentPeriod) > 10) { |
181
|
|
|
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($paymentPeriod)), __LINE__); |
182
|
|
|
} |
183
|
|
|
$this->PaymentPeriod = $paymentPeriod; |
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
/** |
187
|
|
|
* Add item to PaymentPeriod value |
188
|
|
|
* @throws \InvalidArgumentException |
189
|
|
|
* @param \PayPal\StructType\InstallmentDetailsType $item |
190
|
|
|
* @return \PayPal\StructType\OptionSelectionDetailsType |
191
|
|
|
*/ |
192
|
|
|
public function addToPaymentPeriod(\PayPal\StructType\InstallmentDetailsType $item) |
193
|
|
|
{ |
194
|
|
|
// validation for constraint: itemType |
195
|
|
|
if (!$item instanceof \PayPal\StructType\InstallmentDetailsType) { |
|
|
|
|
196
|
|
|
throw new \InvalidArgumentException(sprintf('The PaymentPeriod property can only contain items of type \PayPal\StructType\InstallmentDetailsType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
197
|
|
|
} |
198
|
|
|
// validation for constraint: maxOccurs(10) |
199
|
|
|
if (is_array($this->PaymentPeriod) && count($this->PaymentPeriod) >= 10) { |
200
|
|
|
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->PaymentPeriod)), __LINE__); |
201
|
|
|
} |
202
|
|
|
$this->PaymentPeriod[] = $item; |
203
|
|
|
return $this; |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
|