1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TWrappedFunctionReturnTypeTrait; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType; |
9
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType; |
10
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class representing ParameterAnonymousType |
14
|
|
|
*/ |
15
|
|
|
class ParameterAnonymousType extends IsOK |
16
|
|
|
{ |
17
|
|
|
use IsOKToolboxTrait, TWrappedFunctionReturnTypeTrait; |
18
|
|
|
//Parameter is used to complete function signature: type only. |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @property string $type |
22
|
|
|
*/ |
23
|
|
|
private $type = null; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] $collectionType |
27
|
|
|
*/ |
28
|
|
|
private $collectionType = []; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] $referenceType |
32
|
|
|
*/ |
33
|
|
|
private $referenceType = []; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType |
37
|
|
|
*/ |
38
|
|
|
private $rowType = []; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Gets as type |
42
|
|
|
* |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
|
|
public function getType() |
46
|
|
|
{ |
47
|
|
|
return $this->type; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Sets a new type |
52
|
|
|
* |
53
|
|
|
* @param string $type |
54
|
|
|
* @return self |
55
|
|
|
*/ |
56
|
|
|
public function setType($type) |
57
|
|
|
{ |
58
|
|
|
$this->type = $type; |
59
|
|
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Adds as collectionType |
64
|
|
|
* |
65
|
|
|
* @return self |
66
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType |
67
|
|
|
*/ |
68
|
|
|
public function addToCollectionType(TCollectionTypeType $collectionType) |
69
|
|
|
{ |
70
|
|
|
$this->collectionType[] = $collectionType; |
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* isset collectionType |
76
|
|
|
* |
77
|
|
|
* @param scalar $index |
78
|
|
|
* @return boolean |
79
|
|
|
*/ |
80
|
|
|
public function issetCollectionType($index) |
81
|
|
|
{ |
82
|
|
|
return isset($this->collectionType[$index]); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* unset collectionType |
87
|
|
|
* |
88
|
|
|
* @param scalar $index |
89
|
|
|
* @return void |
90
|
|
|
*/ |
91
|
|
|
public function unsetCollectionType($index) |
92
|
|
|
{ |
93
|
|
|
unset($this->collectionType[$index]); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Gets as collectionType |
98
|
|
|
* |
99
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] |
100
|
|
|
*/ |
101
|
|
|
public function getCollectionType() |
102
|
|
|
{ |
103
|
|
|
return $this->collectionType; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Sets a new collectionType |
108
|
|
|
* |
109
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] $collectionType |
110
|
|
|
* @return self |
111
|
|
|
*/ |
112
|
|
|
public function setCollectionType(array $collectionType) |
113
|
|
|
{ |
114
|
|
|
$this->collectionType = $collectionType; |
115
|
|
|
return $this; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Adds as referenceType |
120
|
|
|
* |
121
|
|
|
* @return self |
122
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType |
123
|
|
|
*/ |
124
|
|
|
public function addToReferenceType(TReferenceTypeType $referenceType) |
125
|
|
|
{ |
126
|
|
|
$this->referenceType[] = $referenceType; |
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* isset referenceType |
132
|
|
|
* |
133
|
|
|
* @param scalar $index |
134
|
|
|
* @return boolean |
135
|
|
|
*/ |
136
|
|
|
public function issetReferenceType($index) |
137
|
|
|
{ |
138
|
|
|
return isset($this->referenceType[$index]); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* unset referenceType |
143
|
|
|
* |
144
|
|
|
* @param scalar $index |
145
|
|
|
* @return void |
146
|
|
|
*/ |
147
|
|
|
public function unsetReferenceType($index) |
148
|
|
|
{ |
149
|
|
|
unset($this->referenceType[$index]); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Gets as referenceType |
154
|
|
|
* |
155
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] |
156
|
|
|
*/ |
157
|
|
|
public function getReferenceType() |
158
|
|
|
{ |
159
|
|
|
return $this->referenceType; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Sets a new referenceType |
164
|
|
|
* |
165
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] $referenceType |
166
|
|
|
* @return self |
167
|
|
|
*/ |
168
|
|
|
public function setReferenceType(array $referenceType) |
169
|
|
|
{ |
170
|
|
|
$this->referenceType = $referenceType; |
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Adds as property |
176
|
|
|
* |
177
|
|
|
* @return self |
178
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property |
179
|
|
|
*/ |
180
|
|
|
public function addToRowType(TPropertyType $property) |
181
|
|
|
{ |
182
|
|
|
$this->rowType[] = $property; |
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* isset rowType |
188
|
|
|
* |
189
|
|
|
* @param scalar $index |
190
|
|
|
* @return boolean |
191
|
|
|
*/ |
192
|
|
|
public function issetRowType($index) |
193
|
|
|
{ |
194
|
|
|
return isset($this->rowType[$index]); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* unset rowType |
199
|
|
|
* |
200
|
|
|
* @param scalar $index |
201
|
|
|
* @return void |
202
|
|
|
*/ |
203
|
|
|
public function unsetRowType($index) |
204
|
|
|
{ |
205
|
|
|
unset($this->rowType[$index]); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Gets as rowType |
210
|
|
|
* |
211
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] |
212
|
|
|
*/ |
213
|
|
|
public function getRowType() |
214
|
|
|
{ |
215
|
|
|
return $this->rowType; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Sets a new rowType |
220
|
|
|
* |
221
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType |
222
|
|
|
* @return self |
223
|
|
|
*/ |
224
|
|
|
public function setRowType(array $rowType) |
225
|
|
|
{ |
226
|
|
|
$this->rowType = $rowType; |
227
|
|
|
return $this; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
public function isOK(&$msg = null) |
231
|
|
|
{ |
232
|
|
|
if (null != $this->type && !$this->isTWrappedFunctionTypeValid($this->type)) { |
233
|
|
|
$msg = "Type must be a valid TWrappedFunctionType"; |
234
|
|
|
return false; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
if (!$this->isValidArrayOK( |
238
|
|
|
$this->collectionType, |
239
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType', |
240
|
|
|
$msg, |
241
|
|
|
0, |
242
|
|
|
1 |
243
|
|
|
)) { |
244
|
|
|
return false; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
if (!$this->isValidArrayOK( |
248
|
|
|
$this->referenceType, |
249
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType', |
250
|
|
|
$msg, |
251
|
|
|
0, |
252
|
|
|
1 |
253
|
|
|
)) { |
254
|
|
|
return false; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
if (!$this->isValidArrayOK( |
258
|
|
|
$this->rowType, |
259
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType', |
260
|
|
|
$msg, |
261
|
|
|
0, |
262
|
|
|
1 |
263
|
|
|
)) { |
264
|
|
|
return false; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
$count = count($this->rowType) + count($this->referenceType) + count($this->collectionType); |
268
|
|
|
if (1 > $count) { |
269
|
|
|
$msg = "Only one component array can be non-empty, and that array must have no more than 1 element"; |
270
|
|
|
return false; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
return true; |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
|