1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PayPal\StructType; |
4
|
|
|
|
5
|
|
|
use \WsdlToPhp\PackageBase\AbstractStructBase; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This class stands for AttributeType StructType |
9
|
|
|
* Meta information extracted from the WSDL |
10
|
|
|
* - documentation: Specific physical attribute of an item. |
11
|
|
|
* @subpackage Structs |
12
|
|
|
* @author WsdlToPhp <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class AttributeType extends AbstractStructBase |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* The Value |
18
|
|
|
* Meta information extracted from the WSDL |
19
|
|
|
* - documentation: ValueList of the Attribute being described by the AttributeID. |
20
|
|
|
* - maxOccurs: unbounded |
21
|
|
|
* @var \PayPal\StructType\ValType[] |
22
|
|
|
*/ |
23
|
|
|
public $Value; |
24
|
|
|
/** |
25
|
|
|
* The AttributeID |
26
|
|
|
* Meta information extracted from the WSDL |
27
|
|
|
* - documentation: Constant name of the attribute that identifies a physical attribute within a set of characteristics that describe something in a formalised way. |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
public $AttributeID; |
31
|
|
|
/** |
32
|
|
|
* Constructor method for AttributeType |
33
|
|
|
* @uses AttributeType::setValue() |
34
|
|
|
* @uses AttributeType::setAttributeID() |
35
|
|
|
* @param \PayPal\StructType\ValType[] $value |
36
|
|
|
* @param string $attributeID |
37
|
|
|
*/ |
38
|
|
|
public function __construct(array $value = array(), $attributeID = null) |
39
|
|
|
{ |
40
|
|
|
$this |
41
|
|
|
->setValue($value) |
42
|
|
|
->setAttributeID($attributeID); |
43
|
|
|
} |
44
|
|
|
/** |
45
|
|
|
* Get Value value |
46
|
|
|
* @return \PayPal\StructType\ValType[]|null |
47
|
|
|
*/ |
48
|
|
|
public function getValue() |
49
|
|
|
{ |
50
|
|
|
return $this->Value; |
51
|
|
|
} |
52
|
|
|
/** |
53
|
|
|
* This method is responsible for validating the values passed to the setValue method |
54
|
|
|
* This method is willingly generated in order to preserve the one-line inline validation within the setValue method |
55
|
|
|
* @param array $values |
56
|
|
|
* @return string A non-empty message if the values does not match the validation rules |
57
|
|
|
*/ |
58
|
|
|
public static function validateValueForArrayConstraintsFromSetValue(array $values = array()) |
59
|
|
|
{ |
60
|
|
|
$message = ''; |
61
|
|
|
$invalidValues = []; |
62
|
|
|
foreach ($values as $attributeTypeValueItem) { |
63
|
|
|
// validation for constraint: itemType |
64
|
|
|
if (!$attributeTypeValueItem instanceof \PayPal\StructType\ValType) { |
65
|
|
|
$invalidValues[] = is_object($attributeTypeValueItem) ? get_class($attributeTypeValueItem) : sprintf('%s(%s)', gettype($attributeTypeValueItem), var_export($attributeTypeValueItem, true)); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
if (!empty($invalidValues)) { |
69
|
|
|
$message = sprintf('The Value property can only contain items of type \PayPal\StructType\ValType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
unset($invalidValues); |
72
|
|
|
return $message; |
73
|
|
|
} |
74
|
|
|
/** |
75
|
|
|
* Set Value value |
76
|
|
|
* @throws \InvalidArgumentException |
77
|
|
|
* @param \PayPal\StructType\ValType[] $value |
78
|
|
|
* @return \PayPal\StructType\AttributeType |
79
|
|
|
*/ |
80
|
|
|
public function setValue(array $value = array()) |
81
|
|
|
{ |
82
|
|
|
// validation for constraint: array |
83
|
|
|
if ('' !== ($valueArrayErrorMessage = self::validateValueForArrayConstraintsFromSetValue($value))) { |
84
|
|
|
throw new \InvalidArgumentException($valueArrayErrorMessage, __LINE__); |
85
|
|
|
} |
86
|
|
|
$this->Value = $value; |
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
/** |
90
|
|
|
* Add item to Value value |
91
|
|
|
* @throws \InvalidArgumentException |
92
|
|
|
* @param \PayPal\StructType\ValType $item |
93
|
|
|
* @return \PayPal\StructType\AttributeType |
94
|
|
|
*/ |
95
|
|
|
public function addToValue(\PayPal\StructType\ValType $item) |
96
|
|
|
{ |
97
|
|
|
// validation for constraint: itemType |
98
|
|
|
if (!$item instanceof \PayPal\StructType\ValType) { |
|
|
|
|
99
|
|
|
throw new \InvalidArgumentException(sprintf('The Value property can only contain items of type \PayPal\StructType\ValType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
100
|
|
|
} |
101
|
|
|
$this->Value[] = $item; |
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
/** |
105
|
|
|
* Get AttributeID value |
106
|
|
|
* @return string|null |
107
|
|
|
*/ |
108
|
|
|
public function getAttributeID() |
109
|
|
|
{ |
110
|
|
|
return $this->AttributeID; |
111
|
|
|
} |
112
|
|
|
/** |
113
|
|
|
* Set AttributeID value |
114
|
|
|
* @param string $attributeID |
115
|
|
|
* @return \PayPal\StructType\AttributeType |
116
|
|
|
*/ |
117
|
|
|
public function setAttributeID($attributeID = null) |
118
|
|
|
{ |
119
|
|
|
// validation for constraint: string |
120
|
|
|
if (!is_null($attributeID) && !is_string($attributeID)) { |
|
|
|
|
121
|
|
|
throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($attributeID, true), gettype($attributeID)), __LINE__); |
122
|
|
|
} |
123
|
|
|
$this->AttributeID = $attributeID; |
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|