1 | <?php |
||
13 | class StructAttribute extends AbstractModel |
||
14 | { |
||
15 | /** |
||
16 | * Type of the struct attribute |
||
17 | * @var string |
||
18 | */ |
||
19 | private $type = ''; |
||
20 | /** |
||
21 | * Defines that this property is not a simple value but an array of values |
||
22 | * Infos at {@link https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints} |
||
23 | * @var bool |
||
24 | */ |
||
25 | private $containsElements = false; |
||
26 | /** |
||
27 | * Defines that this property can be removed from request or not. |
||
28 | * The property cna be removed from the request (meaning from the Struct) as soon as the nillable=true && minOccurs=0 |
||
29 | * Infos at {@link http://www.w3schools.com/xml/el_element.asp} |
||
30 | * @var bool |
||
31 | */ |
||
32 | private $removableFromRequest = false; |
||
33 | /** |
||
34 | * Main constructor |
||
35 | * @see AbstractModel::__construct() |
||
36 | * @uses StructAttribute::setType() |
||
37 | * @uses AbstractModel::setOwner() |
||
38 | * @param Generator $generator |
||
39 | * @param string $name the original name |
||
40 | * @param string $type the type |
||
41 | * @param Struct $struct defines the struct which owns this value |
||
42 | */ |
||
43 | public function __construct(Generator $generator, $name, $type = '', Struct $struct = null) |
||
44 | { |
||
45 | parent::__construct($generator, $name); |
||
46 | $this->setType($type)->setOwner($struct); |
||
47 | } |
||
48 | /** |
||
49 | * Returns the unique name in the current struct (for setters/getters and struct contrusctor array) |
||
50 | * @uses AbstractModel::getCleanName() |
||
51 | * @uses AbstractModel::getName() |
||
52 | * @uses AbstractModel::uniqueName() |
||
53 | * @uses StructAttribute::getOwner() |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getUniqueName() |
||
60 | /** |
||
61 | * Returns the getter name for this attribute |
||
62 | * @uses StructAttribute::getUniqueName() |
||
63 | * @return string |
||
64 | */ |
||
65 | public function getGetterName() |
||
69 | /** |
||
70 | * Returns the getter name for this attribute |
||
71 | * @uses StructAttribute::getUniqueName() |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getSetterName() |
||
78 | /** |
||
79 | * Returns the type value |
||
80 | * @return string |
||
81 | */ |
||
82 | public function getType() |
||
86 | /** |
||
87 | * Sets the type value |
||
88 | * @param string $type |
||
89 | * @return StructAttribute |
||
90 | */ |
||
91 | public function setType($type) |
||
96 | /** |
||
97 | * Returns the type value |
||
98 | * @return bool |
||
99 | */ |
||
100 | public function getContainsElements() |
||
104 | /** |
||
105 | * Sets the type value |
||
106 | * @param bool $containsElements |
||
107 | * @return StructAttribute |
||
108 | */ |
||
109 | public function setContainsElements($containsElements) |
||
114 | /** |
||
115 | * @return bool |
||
116 | */ |
||
117 | public function getRemovableFromRequest() |
||
121 | /** |
||
122 | * @param bool $removableFromRequest |
||
123 | * @return StructAttribute |
||
124 | */ |
||
125 | public function setRemovableFromRequest($removableFromRequest) |
||
130 | /** |
||
131 | * If this attribute contains elements then it's an array |
||
132 | * only if its parent, the Struct, is not itself an array, |
||
133 | * if the parent is an array, then it is certainly not an array too |
||
134 | * @return bool |
||
135 | */ |
||
136 | public function isArray() |
||
140 | /** |
||
141 | * Returns potential default value |
||
142 | * @uses AbstractModel::getMetaValueFirstSet() |
||
143 | * @uses Utils::getValueWithinItsType() |
||
144 | * @uses StructAttribute::getType() |
||
145 | * @uses StructAttribute::getContainsElements() |
||
146 | * @return mixed |
||
147 | */ |
||
148 | public function getDefaultValue() |
||
161 | /** |
||
162 | * Returns true or false depending on minOccurs information associated to the attribute |
||
163 | * @uses AbstractModel::getMetaValueFirstSet() |
||
164 | * @uses AbstractModel::getMetaValue() |
||
165 | * @return bool true|false |
||
166 | */ |
||
167 | public function isRequired() |
||
176 | /** |
||
177 | * Returns the owner model object, meaning a Struct object |
||
178 | * @see AbstractModel::getOwner() |
||
179 | * @uses AbstractModel::getOwner() |
||
180 | * @return Struct |
||
181 | */ |
||
182 | public function getOwner() |
||
186 | /** |
||
187 | * @uses StructAttribute::getType() |
||
188 | * @return bool |
||
189 | */ |
||
190 | public function isXml() |
||
194 | /** |
||
195 | * @return Struct|null |
||
196 | */ |
||
197 | public function getTypeStruct() |
||
201 | /** |
||
202 | * @return string[] |
||
203 | */ |
||
204 | public function getTypeStructMeta() |
||
209 | /** |
||
210 | * @return bool |
||
211 | */ |
||
212 | public function isTypeStructArray() |
||
213 | { |
||
214 | $typeStruct = $this->getTypeStruct(); |
||
215 | return $typeStruct && $typeStruct->isArray() && !$typeStruct->isStruct(); |
||
216 | } |
||
217 | /** |
||
218 | * @return Struct|null |
||
219 | */ |
||
220 | public function getInheritanceStruct() |
||
224 | /** |
||
225 | * @return string[] |
||
226 | */ |
||
227 | public function getInheritanceStructMeta() |
||
232 | /** |
||
233 | * @see \WsdlToPhp\PackageGenerator\Model\AbstractModel::getMeta() |
||
234 | * @return string[] |
||
235 | */ |
||
236 | public function getMeta() |
||
240 | /** |
||
241 | * @param $filename |
||
242 | * @return StructReservedMethod|StructArrayReservedMethod |
||
243 | */ |
||
244 | public function getReservedMethodsInstance($filename = null) |
||
248 | /** |
||
249 | * {@inheritDoc} |
||
250 | * @see \WsdlToPhp\PackageGenerator\Model\AbstractModel::toJsonSerialize() |
||
251 | */ |
||
252 | protected function toJsonSerialize() |
||
260 | } |
||
261 |