1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PayPal\StructType; |
4
|
|
|
|
5
|
|
|
use \WsdlToPhp\PackageBase\AbstractStructBase; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This class stands for MerchantDataType StructType |
9
|
|
|
* Meta information extracted from the WSDL |
10
|
|
|
* - documentation: This holds all key-value pairs which merchants wants to pass it to the open wallet(PLCC) processor. |
11
|
|
|
* @subpackage Structs |
12
|
|
|
* @author WsdlToPhp <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class MerchantDataType extends AbstractStructBase |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* The MerchantDataTuple |
18
|
|
|
* Meta information extracted from the WSDL |
19
|
|
|
* - maxOccurs: 16 |
20
|
|
|
* - minOccurs: 0 |
21
|
|
|
* @var \PayPal\StructType\TupleType[] |
22
|
|
|
*/ |
23
|
|
|
public $MerchantDataTuple; |
24
|
|
|
/** |
25
|
|
|
* Constructor method for MerchantDataType |
26
|
|
|
* @uses MerchantDataType::setMerchantDataTuple() |
27
|
|
|
* @param \PayPal\StructType\TupleType[] $merchantDataTuple |
28
|
|
|
*/ |
29
|
|
|
public function __construct(array $merchantDataTuple = array()) |
30
|
|
|
{ |
31
|
|
|
$this |
32
|
|
|
->setMerchantDataTuple($merchantDataTuple); |
33
|
|
|
} |
34
|
|
|
/** |
35
|
|
|
* Get MerchantDataTuple value |
36
|
|
|
* @return \PayPal\StructType\TupleType[]|null |
37
|
|
|
*/ |
38
|
|
|
public function getMerchantDataTuple() |
39
|
|
|
{ |
40
|
|
|
return $this->MerchantDataTuple; |
41
|
|
|
} |
42
|
|
|
/** |
43
|
|
|
* This method is responsible for validating the values passed to the setMerchantDataTuple method |
44
|
|
|
* This method is willingly generated in order to preserve the one-line inline validation within the setMerchantDataTuple method |
45
|
|
|
* @param array $values |
46
|
|
|
* @return string A non-empty message if the values does not match the validation rules |
47
|
|
|
*/ |
48
|
|
|
public static function validateMerchantDataTupleForArrayConstraintsFromSetMerchantDataTuple(array $values = array()) |
49
|
|
|
{ |
50
|
|
|
$message = ''; |
51
|
|
|
$invalidValues = []; |
52
|
|
|
foreach ($values as $merchantDataTypeMerchantDataTupleItem) { |
53
|
|
|
// validation for constraint: itemType |
54
|
|
|
if (!$merchantDataTypeMerchantDataTupleItem instanceof \PayPal\StructType\TupleType) { |
55
|
|
|
$invalidValues[] = is_object($merchantDataTypeMerchantDataTupleItem) ? get_class($merchantDataTypeMerchantDataTupleItem) : sprintf('%s(%s)', gettype($merchantDataTypeMerchantDataTupleItem), var_export($merchantDataTypeMerchantDataTupleItem, true)); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
if (!empty($invalidValues)) { |
59
|
|
|
$message = sprintf('The MerchantDataTuple property can only contain items of type \PayPal\StructType\TupleType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
unset($invalidValues); |
62
|
|
|
return $message; |
63
|
|
|
} |
64
|
|
|
/** |
65
|
|
|
* Set MerchantDataTuple value |
66
|
|
|
* @throws \InvalidArgumentException |
67
|
|
|
* @param \PayPal\StructType\TupleType[] $merchantDataTuple |
68
|
|
|
* @return \PayPal\StructType\MerchantDataType |
69
|
|
|
*/ |
70
|
|
|
public function setMerchantDataTuple(array $merchantDataTuple = array()) |
71
|
|
|
{ |
72
|
|
|
// validation for constraint: array |
73
|
|
|
if ('' !== ($merchantDataTupleArrayErrorMessage = self::validateMerchantDataTupleForArrayConstraintsFromSetMerchantDataTuple($merchantDataTuple))) { |
74
|
|
|
throw new \InvalidArgumentException($merchantDataTupleArrayErrorMessage, __LINE__); |
75
|
|
|
} |
76
|
|
|
// validation for constraint: maxOccurs(16) |
77
|
|
|
if (is_array($merchantDataTuple) && count($merchantDataTuple) > 16) { |
78
|
|
|
throw new \InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 16', count($merchantDataTuple)), __LINE__); |
79
|
|
|
} |
80
|
|
|
$this->MerchantDataTuple = $merchantDataTuple; |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
/** |
84
|
|
|
* Add item to MerchantDataTuple value |
85
|
|
|
* @throws \InvalidArgumentException |
86
|
|
|
* @param \PayPal\StructType\TupleType $item |
87
|
|
|
* @return \PayPal\StructType\MerchantDataType |
88
|
|
|
*/ |
89
|
|
|
public function addToMerchantDataTuple(\PayPal\StructType\TupleType $item) |
90
|
|
|
{ |
91
|
|
|
// validation for constraint: itemType |
92
|
|
|
if (!$item instanceof \PayPal\StructType\TupleType) { |
|
|
|
|
93
|
|
|
throw new \InvalidArgumentException(sprintf('The MerchantDataTuple property can only contain items of type \PayPal\StructType\TupleType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
94
|
|
|
} |
95
|
|
|
// validation for constraint: maxOccurs(16) |
96
|
|
|
if (is_array($this->MerchantDataTuple) && count($this->MerchantDataTuple) >= 16) { |
97
|
|
|
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 16', count($this->MerchantDataTuple)), __LINE__); |
98
|
|
|
} |
99
|
|
|
$this->MerchantDataTuple[] = $item; |
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|