|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ovh\ArrayType; |
|
4
|
|
|
|
|
5
|
|
|
use \WsdlToPhp\PackageBase\AbstractStructArrayBase; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* This class stands for MyArrayOfServiceLightStructType ArrayType |
|
9
|
|
|
* @subpackage Arrays |
|
10
|
|
|
* @author WsdlToPhp <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class MyArrayOfServiceLightStructType extends AbstractStructArrayBase |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* The item |
|
16
|
|
|
* Meta information extracted from the WSDL |
|
17
|
|
|
* - maxOccurs: unbounded |
|
18
|
|
|
* - minOccurs: 0 |
|
19
|
|
|
* @var \Ovh\StructType\ServiceLightStruct[] |
|
20
|
|
|
*/ |
|
21
|
|
|
public $item; |
|
22
|
|
|
/** |
|
23
|
|
|
* Constructor method for MyArrayOfServiceLightStructType |
|
24
|
|
|
* @uses MyArrayOfServiceLightStructType::setItem() |
|
25
|
|
|
* @param \Ovh\StructType\ServiceLightStruct[] $item |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct(array $item = array()) |
|
28
|
|
|
{ |
|
29
|
|
|
$this |
|
30
|
|
|
->setItem($item); |
|
31
|
|
|
} |
|
32
|
|
|
/** |
|
33
|
|
|
* Get item value |
|
34
|
|
|
* @return \Ovh\StructType\ServiceLightStruct[]|null |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getItem() |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->item; |
|
39
|
|
|
} |
|
40
|
|
|
/** |
|
41
|
|
|
* This method is responsible for validating the values passed to the setItem method |
|
42
|
|
|
* This method is willingly generated in order to preserve the one-line inline validation within the setItem method |
|
43
|
|
|
* @param array $values |
|
44
|
|
|
* @return string A non-empty message if the values does not match the validation rules |
|
45
|
|
|
*/ |
|
46
|
|
|
public static function validateItemForArrayConstraintsFromSetItem(array $values = array()) |
|
47
|
|
|
{ |
|
48
|
|
|
$message = ''; |
|
49
|
|
|
$invalidValues = []; |
|
50
|
|
|
foreach ($values as $myArrayOfServiceLightStructTypeItemItem) { |
|
51
|
|
|
// validation for constraint: itemType |
|
52
|
|
|
if (!$myArrayOfServiceLightStructTypeItemItem instanceof \Ovh\StructType\ServiceLightStruct) { |
|
53
|
|
|
$invalidValues[] = is_object($myArrayOfServiceLightStructTypeItemItem) ? get_class($myArrayOfServiceLightStructTypeItemItem) : sprintf('%s(%s)', gettype($myArrayOfServiceLightStructTypeItemItem), var_export($myArrayOfServiceLightStructTypeItemItem, true)); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
if (!empty($invalidValues)) { |
|
57
|
|
|
$message = sprintf('The item property can only contain items of type \Ovh\StructType\ServiceLightStruct, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
unset($invalidValues); |
|
60
|
|
|
return $message; |
|
61
|
|
|
} |
|
62
|
|
|
/** |
|
63
|
|
|
* Set item value |
|
64
|
|
|
* @throws \InvalidArgumentException |
|
65
|
|
|
* @param \Ovh\StructType\ServiceLightStruct[] $item |
|
66
|
|
|
* @return \Ovh\ArrayType\MyArrayOfServiceLightStructType |
|
67
|
|
|
*/ |
|
68
|
|
|
public function setItem(array $item = array()) |
|
69
|
|
|
{ |
|
70
|
|
|
// validation for constraint: array |
|
71
|
|
|
if ('' !== ($itemArrayErrorMessage = self::validateItemForArrayConstraintsFromSetItem($item))) { |
|
72
|
|
|
throw new \InvalidArgumentException($itemArrayErrorMessage, __LINE__); |
|
73
|
|
|
} |
|
74
|
|
|
$this->item = $item; |
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
/** |
|
78
|
|
|
* Add item to item value |
|
79
|
|
|
* @throws \InvalidArgumentException |
|
80
|
|
|
* @param \Ovh\StructType\ServiceLightStruct $item |
|
81
|
|
|
* @return \Ovh\ArrayType\MyArrayOfServiceLightStructType |
|
82
|
|
|
*/ |
|
83
|
|
|
public function addToItem(\Ovh\StructType\ServiceLightStruct $item) |
|
84
|
|
|
{ |
|
85
|
|
|
// validation for constraint: itemType |
|
86
|
|
|
if (!$item instanceof \Ovh\StructType\ServiceLightStruct) { |
|
|
|
|
|
|
87
|
|
|
throw new \InvalidArgumentException(sprintf('The item property can only contain items of type \Ovh\StructType\ServiceLightStruct, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
|
88
|
|
|
} |
|
89
|
|
|
$this->item[] = $item; |
|
90
|
|
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
/** |
|
93
|
|
|
* Returns the current element |
|
94
|
|
|
* @see AbstractStructArrayBase::current() |
|
95
|
|
|
* @return \Ovh\StructType\ServiceLightStruct|null |
|
96
|
|
|
*/ |
|
97
|
|
|
public function current() |
|
98
|
|
|
{ |
|
99
|
|
|
return parent::current(); |
|
100
|
|
|
} |
|
101
|
|
|
/** |
|
102
|
|
|
* Returns the indexed element |
|
103
|
|
|
* @see AbstractStructArrayBase::item() |
|
104
|
|
|
* @param int $index |
|
105
|
|
|
* @return \Ovh\StructType\ServiceLightStruct|null |
|
106
|
|
|
*/ |
|
107
|
|
|
public function item($index) |
|
108
|
|
|
{ |
|
109
|
|
|
return parent::item($index); |
|
110
|
|
|
} |
|
111
|
|
|
/** |
|
112
|
|
|
* Returns the first element |
|
113
|
|
|
* @see AbstractStructArrayBase::first() |
|
114
|
|
|
* @return \Ovh\StructType\ServiceLightStruct|null |
|
115
|
|
|
*/ |
|
116
|
|
|
public function first() |
|
117
|
|
|
{ |
|
118
|
|
|
return parent::first(); |
|
119
|
|
|
} |
|
120
|
|
|
/** |
|
121
|
|
|
* Returns the last element |
|
122
|
|
|
* @see AbstractStructArrayBase::last() |
|
123
|
|
|
* @return \Ovh\StructType\ServiceLightStruct|null |
|
124
|
|
|
*/ |
|
125
|
|
|
public function last() |
|
126
|
|
|
{ |
|
127
|
|
|
return parent::last(); |
|
128
|
|
|
} |
|
129
|
|
|
/** |
|
130
|
|
|
* Returns the element at the offset |
|
131
|
|
|
* @see AbstractStructArrayBase::offsetGet() |
|
132
|
|
|
* @param int $offset |
|
133
|
|
|
* @return \Ovh\StructType\ServiceLightStruct|null |
|
134
|
|
|
*/ |
|
135
|
|
|
public function offsetGet($offset) |
|
136
|
|
|
{ |
|
137
|
|
|
return parent::offsetGet($offset); |
|
138
|
|
|
} |
|
139
|
|
|
/** |
|
140
|
|
|
* Returns the attribute name |
|
141
|
|
|
* @see AbstractStructArrayBase::getAttributeName() |
|
142
|
|
|
* @return string item |
|
143
|
|
|
*/ |
|
144
|
|
|
public function getAttributeName() |
|
145
|
|
|
{ |
|
146
|
|
|
return 'item'; |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|