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\TWrappedFunctionReturnTypeTrait; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class representing TTypeTestExpressionType |
11
|
|
|
* |
12
|
|
|
* |
13
|
|
|
* XSD Type: TTypeTestExpression |
14
|
|
|
*/ |
15
|
|
|
class TTypeTestExpressionType extends IsOK |
16
|
|
|
{ |
17
|
|
|
use TFacetAttributesTrait, TWrappedFunctionReturnTypeTrait; |
18
|
|
|
/** |
19
|
|
|
* @property string $type |
20
|
|
|
*/ |
21
|
|
|
private $type = null; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType[] $operand |
25
|
|
|
*/ |
26
|
|
|
private $operand = []; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] $collectionType |
30
|
|
|
*/ |
31
|
|
|
private $collectionType = []; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] $referenceType |
35
|
|
|
*/ |
36
|
|
|
private $referenceType = []; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType |
40
|
|
|
*/ |
41
|
|
|
private $rowType = []; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Gets as type |
45
|
|
|
* |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getType() |
49
|
|
|
{ |
50
|
|
|
return $this->type; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Sets a new type |
55
|
|
|
* |
56
|
|
|
* @param string $type |
57
|
|
|
* @return self |
58
|
|
|
*/ |
59
|
|
|
public function setType($type) |
60
|
|
|
{ |
61
|
|
|
$this->type = $type; |
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Adds as operand |
67
|
|
|
* |
68
|
|
|
* @return self |
69
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType $operand |
70
|
|
|
*/ |
71
|
|
|
public function addToOperand(TOperandType $operand) |
72
|
|
|
{ |
73
|
|
|
$this->operand[] = $operand; |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* isset operand |
79
|
|
|
* |
80
|
|
|
* @param scalar $index |
81
|
|
|
* @return boolean |
82
|
|
|
*/ |
83
|
|
|
public function issetOperand($index) |
84
|
|
|
{ |
85
|
|
|
return isset($this->operand[$index]); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* unset operand |
90
|
|
|
* |
91
|
|
|
* @param scalar $index |
92
|
|
|
* @return void |
93
|
|
|
*/ |
94
|
|
|
public function unsetOperand($index) |
95
|
|
|
{ |
96
|
|
|
unset($this->operand[$index]); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Gets as operand |
101
|
|
|
* |
102
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType[] |
103
|
|
|
*/ |
104
|
|
|
public function getOperand() |
105
|
|
|
{ |
106
|
|
|
return $this->operand; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Sets a new operand |
111
|
|
|
* |
112
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType[] $operand |
113
|
|
|
* @return self |
114
|
|
|
*/ |
115
|
|
|
public function setOperand(array $operand) |
116
|
|
|
{ |
117
|
|
|
$this->operand = $operand; |
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Adds as collectionType |
123
|
|
|
* |
124
|
|
|
* @return self |
125
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType |
126
|
|
|
*/ |
127
|
|
|
public function addToCollectionType(TCollectionTypeType $collectionType) |
128
|
|
|
{ |
129
|
|
|
$this->collectionType[] = $collectionType; |
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* isset collectionType |
135
|
|
|
* |
136
|
|
|
* @param scalar $index |
137
|
|
|
* @return boolean |
138
|
|
|
*/ |
139
|
|
|
public function issetCollectionType($index) |
140
|
|
|
{ |
141
|
|
|
return isset($this->collectionType[$index]); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* unset collectionType |
146
|
|
|
* |
147
|
|
|
* @param scalar $index |
148
|
|
|
* @return void |
149
|
|
|
*/ |
150
|
|
|
public function unsetCollectionType($index) |
151
|
|
|
{ |
152
|
|
|
unset($this->collectionType[$index]); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Gets as collectionType |
157
|
|
|
* |
158
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] |
159
|
|
|
*/ |
160
|
|
|
public function getCollectionType() |
161
|
|
|
{ |
162
|
|
|
return $this->collectionType; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Sets a new collectionType |
167
|
|
|
* |
168
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] $collectionType |
169
|
|
|
* @return self |
170
|
|
|
*/ |
171
|
|
|
public function setCollectionType(array $collectionType) |
172
|
|
|
{ |
173
|
|
|
$this->collectionType = $collectionType; |
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Adds as referenceType |
179
|
|
|
* |
180
|
|
|
* @return self |
181
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType |
182
|
|
|
*/ |
183
|
|
|
public function addToReferenceType(TReferenceTypeType $referenceType) |
184
|
|
|
{ |
185
|
|
|
$this->referenceType[] = $referenceType; |
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* isset referenceType |
191
|
|
|
* |
192
|
|
|
* @param scalar $index |
193
|
|
|
* @return boolean |
194
|
|
|
*/ |
195
|
|
|
public function issetReferenceType($index) |
196
|
|
|
{ |
197
|
|
|
return isset($this->referenceType[$index]); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* unset referenceType |
202
|
|
|
* |
203
|
|
|
* @param scalar $index |
204
|
|
|
* @return void |
205
|
|
|
*/ |
206
|
|
|
public function unsetReferenceType($index) |
207
|
|
|
{ |
208
|
|
|
unset($this->referenceType[$index]); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Gets as referenceType |
213
|
|
|
* |
214
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] |
215
|
|
|
*/ |
216
|
|
|
public function getReferenceType() |
217
|
|
|
{ |
218
|
|
|
return $this->referenceType; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Sets a new referenceType |
223
|
|
|
* |
224
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] $referenceType |
225
|
|
|
* @return self |
226
|
|
|
*/ |
227
|
|
|
public function setReferenceType(array $referenceType) |
228
|
|
|
{ |
229
|
|
|
$this->referenceType = $referenceType; |
230
|
|
|
return $this; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Adds as property |
235
|
|
|
* |
236
|
|
|
* @return self |
237
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property |
238
|
|
|
*/ |
239
|
|
|
public function addToRowType(TPropertyType $property) |
240
|
|
|
{ |
241
|
|
|
$this->rowType[] = $property; |
242
|
|
|
return $this; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* isset rowType |
247
|
|
|
* |
248
|
|
|
* @param scalar $index |
249
|
|
|
* @return boolean |
250
|
|
|
*/ |
251
|
|
|
public function issetRowType($index) |
252
|
|
|
{ |
253
|
|
|
return isset($this->rowType[$index]); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* unset rowType |
258
|
|
|
* |
259
|
|
|
* @param scalar $index |
260
|
|
|
* @return void |
261
|
|
|
*/ |
262
|
|
|
public function unsetRowType($index) |
263
|
|
|
{ |
264
|
|
|
unset($this->rowType[$index]); |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* Gets as rowType |
269
|
|
|
* |
270
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] |
271
|
|
|
*/ |
272
|
|
|
public function getRowType() |
273
|
|
|
{ |
274
|
|
|
return $this->rowType; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* Sets a new rowType |
279
|
|
|
* |
280
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType |
281
|
|
|
* @return self |
282
|
|
|
*/ |
283
|
|
|
public function setRowType(array $rowType) |
284
|
|
|
{ |
285
|
|
|
$this->rowType = $rowType; |
286
|
|
|
return $this; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
public function isOK(&$msg = null) |
290
|
|
|
{ |
291
|
|
|
if (null != $this->type && !$this->isTWrappedFunctionTypeValid($this->type)) { |
292
|
|
|
$msg = "Type must be a valid TWrappedFunctionType"; |
293
|
|
|
return false; |
294
|
|
|
} |
295
|
|
|
if (!$this->isTFacetAttributesTraitValid($msg)) { |
296
|
|
|
return false; |
297
|
|
|
} |
298
|
|
|
if (!$this->isValidArrayOK( |
299
|
|
|
$this->collectionType, |
300
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType', |
301
|
|
|
$msg |
302
|
|
|
)) { |
303
|
|
|
return false; |
304
|
|
|
} |
305
|
|
|
if (!$this->isValidArrayOK( |
306
|
|
|
$this->referenceType, |
307
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType', |
308
|
|
|
$msg |
309
|
|
|
)) { |
310
|
|
|
return false; |
311
|
|
|
} |
312
|
|
|
if (!$this->isValidArrayOK( |
313
|
|
|
$this->rowType, |
314
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType', |
315
|
|
|
$msg |
316
|
|
|
)) { |
317
|
|
|
return false; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
if (!$this->isValidArrayOK( |
321
|
|
|
$this->operand, |
322
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType', |
323
|
|
|
$msg |
324
|
|
|
)) { |
325
|
|
|
return false; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
$count = 0 < count($this->collectionType) ? 1 : 0 |
329
|
|
|
+ 0 < count($this->referenceType) ? 1 : 0 |
330
|
|
|
+ 0 < count($this->rowType) ? 1 : 0; |
331
|
|
|
if (1 < $count) { |
332
|
|
|
$msg = "At most one of collection type, reference type and row type can be set"; |
333
|
|
|
return false; |
334
|
|
|
} |
335
|
|
|
if (0 == $count && 0 == count($this->operand)) { |
336
|
|
|
$msg = "If all of collection type, reference type and row type are empty, operand must not be empty"; |
337
|
|
|
return false; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
return true; |
341
|
|
|
} |
342
|
|
|
} |
343
|
|
|
|