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\TSimpleIdentifierTrait; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TCommandTextTrait; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class representing TFunctionType |
12
|
|
|
* |
13
|
|
|
* |
14
|
|
|
* XSD Type: TFunction |
15
|
|
|
*/ |
16
|
|
|
class TFunctionType extends IsOK |
17
|
|
|
{ |
18
|
|
|
use TFacetAttributesTrait, TCommandTextTrait, TSimpleIdentifierTrait; |
19
|
|
|
/** |
20
|
|
|
* @property string $name |
21
|
|
|
*/ |
22
|
|
|
private $name = null; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReturnTypeType[] $returnType |
26
|
|
|
*/ |
27
|
|
|
private $returnType = []; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation |
31
|
|
|
*/ |
32
|
|
|
private $documentation = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionParameterType[] $parameter |
36
|
|
|
*/ |
37
|
|
|
private $parameter = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @property string[] $definingExpression |
41
|
|
|
*/ |
42
|
|
|
private $definingExpression = []; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Gets as name |
46
|
|
|
* |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
|
|
public function getName() |
50
|
|
|
{ |
51
|
|
|
return $this->name; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Sets a new name |
56
|
|
|
* |
57
|
|
|
* @param string $name |
58
|
|
|
* @return self |
59
|
|
|
*/ |
60
|
|
|
public function setName($name) |
61
|
|
|
{ |
62
|
|
|
$this->name = $name; |
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Adds as returnType |
68
|
|
|
* |
69
|
|
|
* @return self |
70
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReturnTypeType $returnType |
71
|
|
|
*/ |
72
|
|
|
public function addToReturnType(TFunctionReturnTypeType $returnType) |
73
|
|
|
{ |
74
|
|
|
$this->returnType[] = $returnType; |
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* isset returnType |
80
|
|
|
* |
81
|
|
|
* @param scalar $index |
82
|
|
|
* @return boolean |
83
|
|
|
*/ |
84
|
|
|
public function issetReturnType($index) |
85
|
|
|
{ |
86
|
|
|
return isset($this->returnType[$index]); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* unset returnType |
91
|
|
|
* |
92
|
|
|
* @param scalar $index |
93
|
|
|
* @return void |
94
|
|
|
*/ |
95
|
|
|
public function unsetReturnType($index) |
96
|
|
|
{ |
97
|
|
|
unset($this->returnType[$index]); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Gets as returnType |
102
|
|
|
* |
103
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReturnTypeType[] |
104
|
|
|
*/ |
105
|
|
|
public function getReturnType() |
106
|
|
|
{ |
107
|
|
|
return $this->returnType; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Sets a new returnType |
112
|
|
|
* |
113
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReturnTypeType[] $returnType |
114
|
|
|
* @return self |
115
|
|
|
*/ |
116
|
|
|
public function setReturnType(array $returnType) |
117
|
|
|
{ |
118
|
|
|
$this->returnType = $returnType; |
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Gets as documentation |
124
|
|
|
* |
125
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType |
126
|
|
|
*/ |
127
|
|
|
public function getDocumentation() |
128
|
|
|
{ |
129
|
|
|
return $this->documentation; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Sets a new documentation |
134
|
|
|
* |
135
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TDocumentationType $documentation |
136
|
|
|
* @return self |
137
|
|
|
*/ |
138
|
|
|
public function setDocumentation(TDocumentationType $documentation) |
139
|
|
|
{ |
140
|
|
|
$this->documentation = $documentation; |
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Adds as parameter |
146
|
|
|
* |
147
|
|
|
* @return self |
148
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionParameterType $parameter |
149
|
|
|
*/ |
150
|
|
|
public function addToParameter(TFunctionParameterType $parameter) |
151
|
|
|
{ |
152
|
|
|
$this->parameter[] = $parameter; |
153
|
|
|
return $this; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* isset parameter |
158
|
|
|
* |
159
|
|
|
* @param scalar $index |
160
|
|
|
* @return boolean |
161
|
|
|
*/ |
162
|
|
|
public function issetParameter($index) |
163
|
|
|
{ |
164
|
|
|
return isset($this->parameter[$index]); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* unset parameter |
169
|
|
|
* |
170
|
|
|
* @param scalar $index |
171
|
|
|
* @return void |
172
|
|
|
*/ |
173
|
|
|
public function unsetParameter($index) |
174
|
|
|
{ |
175
|
|
|
unset($this->parameter[$index]); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Gets as parameter |
180
|
|
|
* |
181
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionParameterType[] |
182
|
|
|
*/ |
183
|
|
|
public function getParameter() |
184
|
|
|
{ |
185
|
|
|
return $this->parameter; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* Sets a new parameter |
190
|
|
|
* |
191
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionParameterType[] $parameter |
192
|
|
|
* @return self |
193
|
|
|
*/ |
194
|
|
|
public function setParameter(array $parameter) |
195
|
|
|
{ |
196
|
|
|
$this->parameter = $parameter; |
197
|
|
|
return $this; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Adds as definingExpression |
202
|
|
|
* |
203
|
|
|
* @return self |
204
|
|
|
* @param string $definingExpression |
205
|
|
|
*/ |
206
|
|
|
public function addToDefiningExpression($definingExpression) |
207
|
|
|
{ |
208
|
|
|
$this->definingExpression[] = $definingExpression; |
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* isset definingExpression |
214
|
|
|
* |
215
|
|
|
* @param scalar $index |
216
|
|
|
* @return boolean |
217
|
|
|
*/ |
218
|
|
|
public function issetDefiningExpression($index) |
219
|
|
|
{ |
220
|
|
|
return isset($this->definingExpression[$index]); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* unset definingExpression |
225
|
|
|
* |
226
|
|
|
* @param scalar $index |
227
|
|
|
* @return void |
228
|
|
|
*/ |
229
|
|
|
public function unsetDefiningExpression($index) |
230
|
|
|
{ |
231
|
|
|
unset($this->definingExpression[$index]); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Gets as definingExpression |
236
|
|
|
* |
237
|
|
|
* @return string[] |
238
|
|
|
*/ |
239
|
|
|
public function getDefiningExpression() |
240
|
|
|
{ |
241
|
|
|
return $this->definingExpression; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Sets a new definingExpression |
246
|
|
|
* |
247
|
|
|
* @param string $definingExpression |
248
|
|
|
* @return self |
249
|
|
|
*/ |
250
|
|
|
public function setDefiningExpression(array $definingExpression) |
251
|
|
|
{ |
252
|
|
|
$this->definingExpression = $definingExpression; |
253
|
|
|
return $this; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
public function isOK(&$msg = null) |
257
|
|
|
{ |
258
|
|
|
if (!$this->isTSimpleIdentifierValid($this->name)) { |
259
|
|
|
$msg = "Name must be a valid TSimpleIdentifier"; |
260
|
|
|
return false; |
261
|
|
|
} |
262
|
|
|
if (!$this->isObjectNullOrOK($this->documentation, $msg)) { |
263
|
|
|
return false; |
264
|
|
|
} |
265
|
|
|
if (!$this->isValidArrayOK( |
266
|
|
|
$this->parameter, |
267
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionParameterType', |
268
|
|
|
$msg |
269
|
|
|
)) { |
270
|
|
|
return false; |
271
|
|
|
} |
272
|
|
|
if (!$this->isValidArrayOK( |
273
|
|
|
$this->returnType, |
274
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReturnTypeType', |
275
|
|
|
$msg |
276
|
|
|
)) { |
277
|
|
|
return false; |
278
|
|
|
} |
279
|
|
|
foreach ($this->returnType as $type) { |
280
|
|
|
if (!is_string($type) || !$this->isTCommandTextValid($type)) { |
281
|
|
|
$msg = $type . " must be a valid TCommandText"; |
282
|
|
|
return false; |
283
|
|
|
} |
284
|
|
|
} |
285
|
|
|
if (!$this->isTFacetAttributesTraitValid($msg)) { |
286
|
|
|
return false; |
287
|
|
|
} |
288
|
|
|
return true; |
289
|
|
|
} |
290
|
|
|
} |
291
|
|
|
|