1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\Groups\TFacetAttributesTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TUnwrappedFunctionTypeTrait; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class representing TCollectionTypeType |
11
|
|
|
* |
12
|
|
|
* |
13
|
|
|
* XSD Type: TCollectionType |
14
|
|
|
*/ |
15
|
|
|
class TCollectionTypeType extends IsOK |
16
|
|
|
{ |
17
|
|
|
use TFacetAttributesTrait, TUnwrappedFunctionTypeTrait; |
18
|
|
|
/** |
19
|
|
|
* @property string $elementType |
20
|
|
|
*/ |
21
|
|
|
private $elementType = null; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType |
25
|
|
|
*/ |
26
|
|
|
private $collectionType = null; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType |
30
|
|
|
*/ |
31
|
|
|
private $referenceType = null; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType |
35
|
|
|
*/ |
36
|
|
|
private $rowType = []; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeRefType $typeRef |
40
|
|
|
*/ |
41
|
|
|
private $typeRef = null; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Gets as elementType |
45
|
|
|
* |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getElementType() |
49
|
|
|
{ |
50
|
|
|
return $this->elementType; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Sets a new elementType |
55
|
|
|
* |
56
|
|
|
* @param string $elementType |
57
|
|
|
* @return self |
58
|
|
|
*/ |
59
|
|
|
public function setElementType($elementType) |
60
|
|
|
{ |
61
|
|
|
$this->elementType = $elementType; |
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Gets as collectionType |
67
|
|
|
* |
68
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType |
69
|
|
|
*/ |
70
|
|
|
public function getCollectionType() |
71
|
|
|
{ |
72
|
|
|
return $this->collectionType; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Sets a new collectionType |
77
|
|
|
* |
78
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType |
79
|
|
|
* @return self |
80
|
|
|
*/ |
81
|
|
|
public function setCollectionType(TCollectionTypeType $collectionType) |
82
|
|
|
{ |
83
|
|
|
$this->collectionType = $collectionType; |
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Gets as referenceType |
89
|
|
|
* |
90
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType |
91
|
|
|
*/ |
92
|
|
|
public function getReferenceType() |
93
|
|
|
{ |
94
|
|
|
return $this->referenceType; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Sets a new referenceType |
99
|
|
|
* |
100
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType |
101
|
|
|
* @return self |
102
|
|
|
*/ |
103
|
|
|
public function setReferenceType(TReferenceTypeType $referenceType) |
104
|
|
|
{ |
105
|
|
|
$this->referenceType = $referenceType; |
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Adds as property |
111
|
|
|
* |
112
|
|
|
* @return self |
113
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property |
114
|
|
|
*/ |
115
|
|
|
public function addToRowType(TPropertyType $property) |
116
|
|
|
{ |
117
|
|
|
$this->rowType[] = $property; |
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* isset rowType |
123
|
|
|
* |
124
|
|
|
* @param scalar $index |
125
|
|
|
* @return boolean |
126
|
|
|
*/ |
127
|
|
|
public function issetRowType($index) |
128
|
|
|
{ |
129
|
|
|
return isset($this->rowType[$index]); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* unset rowType |
134
|
|
|
* |
135
|
|
|
* @param scalar $index |
136
|
|
|
* @return void |
137
|
|
|
*/ |
138
|
|
|
public function unsetRowType($index) |
139
|
|
|
{ |
140
|
|
|
unset($this->rowType[$index]); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Gets as rowType |
145
|
|
|
* |
146
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] |
147
|
|
|
*/ |
148
|
|
|
public function getRowType() |
149
|
|
|
{ |
150
|
|
|
return $this->rowType; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Sets a new rowType |
155
|
|
|
* |
156
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType |
157
|
|
|
* @return self |
158
|
|
|
*/ |
159
|
|
|
public function setRowType(array $rowType) |
160
|
|
|
{ |
161
|
|
|
$this->rowType = $rowType; |
162
|
|
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Gets as typeRef |
167
|
|
|
* |
168
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeRefType |
169
|
|
|
*/ |
170
|
|
|
public function getTypeRef() |
171
|
|
|
{ |
172
|
|
|
return $this->typeRef; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Sets a new typeRef |
177
|
|
|
* |
178
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeRefType $typeRef |
179
|
|
|
* @return self |
180
|
|
|
*/ |
181
|
|
|
public function setTypeRef(TTypeRefType $typeRef) |
182
|
|
|
{ |
183
|
|
|
$this->typeRef = $typeRef; |
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function isOK(&$msg = null) |
188
|
|
|
{ |
189
|
|
|
if (null != $this->elementType && !$this->isTUnwrappedFunctionTypeValid($this->elementType)) { |
190
|
|
|
$msg = "Element type must be a valid TUnwrappedFunction"; |
191
|
|
|
return false; |
192
|
|
|
} |
193
|
|
|
if (!$this->isTFacetAttributesTraitValid($msg)) { |
194
|
|
|
return false; |
195
|
|
|
} |
196
|
|
|
if (!$this->isObjectNullOrOK($this->collectionType, $msg)) { |
197
|
|
|
return false; |
198
|
|
|
} |
199
|
|
|
if (!$this->isObjectNullOrOK($this->referenceType, $msg)) { |
200
|
|
|
return false; |
201
|
|
|
} |
202
|
|
|
if (!$this->isValidArray($this->rowType, '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType', $msg)) { |
203
|
|
|
return false; |
204
|
|
|
} |
205
|
|
|
if (!$this->isObjectNullOrOK($this->typeRef, $msg)) { |
206
|
|
|
return false; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
$count = (isset($this->collectionType) ? 1 : 0) + (isset($this->referenceType) ? 1 : 0) |
210
|
|
|
+ (0 < count($this->rowType) ? 1 : 0) + (isset($this->typeRef) ? 1 : 0); |
211
|
|
|
if (1 != $count) { |
212
|
|
|
$msg = "Exactly one of collection type and reference type must not be null"; |
213
|
|
|
return false; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
return true; |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
|