1 | <?php |
||
11 | class StructAttribute extends AbstractModel |
||
12 | { |
||
13 | /** |
||
14 | * Type of the struct attribute |
||
15 | * @var string |
||
16 | */ |
||
17 | private $type = ''; |
||
18 | /** |
||
19 | * Defines that this property is not a simple value but an array of values |
||
20 | * Infos at {@link https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints} |
||
21 | * @var bool |
||
22 | */ |
||
23 | private $containsElements = false; |
||
24 | /** |
||
25 | * Main constructor |
||
26 | * @see AbstractModel::__construct() |
||
27 | * @uses StructAttribute::setType() |
||
28 | * @uses AbstractModel::setOwner() |
||
29 | * @param Generator $generator |
||
30 | * @param string $name the original name |
||
31 | * @param string $type the type |
||
32 | * @param Struct $struct defines the struct which owns this value |
||
33 | */ |
||
34 | 408 | public function __construct(Generator $generator, $name, $type, Struct $struct) |
|
35 | { |
||
36 | 408 | parent::__construct($generator, $name); |
|
37 | 408 | $this->setType($type); |
|
38 | 408 | $this->setOwner($struct); |
|
39 | 408 | } |
|
40 | /** |
||
41 | * Returns the unique name in the current struct (for setters/getters and struct contrusctor array) |
||
42 | * @uses AbstractModel::getCleanName() |
||
43 | * @uses AbstractModel::getName() |
||
44 | * @uses AbstractModel::uniqueName() |
||
45 | * @uses StructAttribute::getOwner() |
||
46 | * @return string |
||
47 | */ |
||
48 | 80 | public function getUniqueName() |
|
49 | { |
||
50 | 80 | return self::uniqueName($this->getCleanName(), $this->getOwner()->getName()); |
|
51 | } |
||
52 | /** |
||
53 | * Returns the getter name for this attribute |
||
54 | * @uses StructAttribute::getUniqueName() |
||
55 | * @return string |
||
56 | */ |
||
57 | 76 | public function getGetterName() |
|
58 | { |
||
59 | 76 | return sprintf('get%s', ucfirst(self::getUniqueName())); |
|
60 | } |
||
61 | /** |
||
62 | * Returns the getter name for this attribute |
||
63 | * @uses StructAttribute::getUniqueName() |
||
64 | * @return string |
||
65 | */ |
||
66 | 76 | public function getSetterName() |
|
67 | { |
||
68 | 76 | return sprintf('set%s', ucfirst(self::getUniqueName())); |
|
69 | } |
||
70 | /** |
||
71 | * Returns the type value |
||
72 | * @return string |
||
73 | */ |
||
74 | 256 | public function getType() |
|
75 | { |
||
76 | 256 | return $this->type; |
|
77 | } |
||
78 | /** |
||
79 | * Sets the type value |
||
80 | * @param string $type |
||
81 | * @return StructAttribute |
||
82 | */ |
||
83 | 408 | public function setType($type) |
|
84 | { |
||
85 | 408 | $this->type = $type; |
|
86 | 408 | return $this; |
|
87 | } |
||
88 | /** |
||
89 | * Returns the type value |
||
90 | * @return bool |
||
91 | */ |
||
92 | 4 | public function getContainsElements() |
|
96 | /** |
||
97 | * Sets the type value |
||
98 | * @param bool $containsElements |
||
99 | * @return StructAttribute |
||
100 | */ |
||
101 | 244 | public function setContainsElements($containsElements) |
|
106 | /** |
||
107 | * If this attribute contains elements then it's an array |
||
108 | * only if its parent, the Struct, is not itself an array, |
||
109 | * if the parent is an array, then it is certainly not an array too |
||
110 | * @return bool |
||
111 | */ |
||
112 | 76 | public function isArray() |
|
116 | /** |
||
117 | * Returns potential default value |
||
118 | * @uses AbstractModel::getMetaValueFirstSet() |
||
119 | * @uses Utils::getValueWithinItsType() |
||
120 | * @uses StructAttribute::getType() |
||
121 | * @uses StructAttribute::getContainsElements() |
||
122 | * @return mixed |
||
123 | */ |
||
124 | 76 | public function getDefaultValue() |
|
137 | /** |
||
138 | * Returns true or false depending on minOccurs information associated to the attribute |
||
139 | * @uses AbstractModel::getMetaValueFirstSet() |
||
140 | * @uses AbstractModel::getMetaValue() |
||
141 | * @return bool true|false |
||
142 | */ |
||
143 | 76 | public function isRequired() |
|
152 | /** |
||
153 | * Returns the owner model object, meaning a Struct object |
||
154 | * @see AbstractModel::getOwner() |
||
155 | * @uses AbstractModel::getOwner() |
||
156 | * @return Struct |
||
157 | */ |
||
158 | 80 | public function getOwner() |
|
162 | /** |
||
163 | * @uses StructAttribute::getType() |
||
164 | * @return bool |
||
165 | */ |
||
166 | 76 | public function isXml() |
|
170 | /** |
||
171 | * @return Struct|null |
||
172 | */ |
||
173 | 88 | public function getTypeStruct() |
|
177 | /** |
||
178 | * @return Struct|null |
||
179 | */ |
||
180 | 88 | public function getInheritanceStruct() |
|
184 | /** |
||
185 | * @see \WsdlToPhp\PackageGenerator\Model\AbstractModel::getMeta() |
||
186 | * @return string[] |
||
187 | */ |
||
188 | 88 | public function getMeta() |
|
194 | } |
||
195 |