1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\mapping\cs; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\IsOKTraits\TQualifiedNameTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV4\edm\IsOKTraits\TSimpleIdentifierTrait; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class representing TAssociationSetMappingType |
11
|
|
|
* |
12
|
|
|
* Type for AssociationSetMapping element |
13
|
|
|
* |
14
|
|
|
* XSD Type: TAssociationSetMapping |
15
|
|
|
*/ |
16
|
|
|
class TAssociationSetMappingType extends IsOK |
17
|
|
|
{ |
18
|
|
|
use TSimpleIdentifierTrait, TQualifiedNameTrait; |
19
|
|
|
/** |
20
|
|
|
* @property string $name |
21
|
|
|
*/ |
22
|
|
|
private $name = null; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @property string $typeName |
26
|
|
|
*/ |
27
|
|
|
private $typeName = null; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @property string $storeEntitySet |
31
|
|
|
*/ |
32
|
|
|
private $storeEntitySet = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @property string $queryView |
36
|
|
|
*/ |
37
|
|
|
private $queryView = null; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType[] $endProperty |
41
|
|
|
*/ |
42
|
|
|
private $endProperty = []; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] $condition |
46
|
|
|
*/ |
47
|
|
|
private $condition = []; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetModificationFunctionMappingType |
51
|
|
|
* $modificationFunctionMapping |
52
|
|
|
*/ |
53
|
|
|
private $modificationFunctionMapping = null; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Gets as name |
57
|
|
|
* |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function getName() |
61
|
|
|
{ |
62
|
|
|
return $this->name; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Sets a new name |
67
|
|
|
* |
68
|
|
|
* @param string $name |
69
|
|
|
* @return self |
70
|
|
|
*/ |
71
|
|
|
public function setName($name) |
72
|
|
|
{ |
73
|
|
|
if (!$this->isStringNotNullOrEmpty($name)) { |
74
|
|
|
$msg = 'Name cannot be null or empty'; |
75
|
|
|
throw new \InvalidArgumentException($msg); |
76
|
|
|
} |
77
|
|
|
if (!$this->isTSimpleIdentifierValid($name)) { |
78
|
|
|
$msg = 'Name must be a valid TSimpleIdentifier'; |
79
|
|
|
throw new \InvalidArgumentException($msg); |
80
|
|
|
} |
81
|
|
|
$this->name = $name; |
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Gets as typeName |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getTypeName() |
91
|
|
|
{ |
92
|
|
|
return $this->typeName; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Sets a new typeName |
97
|
|
|
* |
98
|
|
|
* @param string $typeName |
99
|
|
|
* @return self |
100
|
|
|
*/ |
101
|
|
|
public function setTypeName($typeName) |
102
|
|
|
{ |
103
|
|
|
if (null != $typeName && !$this->isStringNotNullOrEmpty($typeName)) { |
104
|
|
|
$msg = 'Type name cannot be empty'; |
105
|
|
|
throw new \InvalidArgumentException($msg); |
106
|
|
|
} |
107
|
|
|
if (null != $typeName && !$this->isTQualifiedNameValid($typeName)) { |
108
|
|
|
$msg = 'Type name must be a valid TQualifiedName'; |
109
|
|
|
throw new \InvalidArgumentException($msg); |
110
|
|
|
} |
111
|
|
|
$this->typeName = $typeName; |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Gets as storeEntitySet |
117
|
|
|
* |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
|
|
public function getStoreEntitySet() |
121
|
|
|
{ |
122
|
|
|
return $this->storeEntitySet; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Sets a new storeEntitySet |
127
|
|
|
* |
128
|
|
|
* @param string $storeEntitySet |
129
|
|
|
* @return self |
130
|
|
|
*/ |
131
|
|
View Code Duplication |
public function setStoreEntitySet($storeEntitySet) |
|
|
|
|
132
|
|
|
{ |
133
|
|
|
if (null != $storeEntitySet && !$this->isStringNotNullOrEmpty($storeEntitySet)) { |
134
|
|
|
$msg = 'Store entity set cannot be empty'; |
135
|
|
|
throw new \InvalidArgumentException($msg); |
136
|
|
|
} |
137
|
|
|
$this->storeEntitySet = $storeEntitySet; |
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Gets as queryView |
143
|
|
|
* |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
public function getQueryView() |
147
|
|
|
{ |
148
|
|
|
return $this->queryView; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Sets a new queryView |
153
|
|
|
* |
154
|
|
|
* @param string $queryView |
155
|
|
|
* @return self |
156
|
|
|
*/ |
157
|
|
View Code Duplication |
public function setQueryView($queryView) |
|
|
|
|
158
|
|
|
{ |
159
|
|
|
if (null != $queryView && !$this->isStringNotNullOrEmpty($queryView)) { |
160
|
|
|
$msg = 'Query view cannot be empty'; |
161
|
|
|
throw new \InvalidArgumentException($msg); |
162
|
|
|
} |
163
|
|
|
$this->queryView = $queryView; |
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Adds as endProperty |
169
|
|
|
* |
170
|
|
|
* @return self |
171
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType $endProperty |
172
|
|
|
*/ |
173
|
|
View Code Duplication |
public function addToEndProperty(TEndPropertyType $endProperty) |
|
|
|
|
174
|
|
|
{ |
175
|
|
|
$msg = null; |
176
|
|
|
if (!$endProperty->isOK($msg)) { |
177
|
|
|
throw new \InvalidArgumentException($msg); |
178
|
|
|
} |
179
|
|
|
$this->endProperty[] = $endProperty; |
180
|
|
|
return $this; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* isset endProperty |
185
|
|
|
* |
186
|
|
|
* @param scalar $index |
187
|
|
|
* @return boolean |
188
|
|
|
*/ |
189
|
|
|
public function issetEndProperty($index) |
190
|
|
|
{ |
191
|
|
|
return isset($this->endProperty[$index]); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* unset endProperty |
196
|
|
|
* |
197
|
|
|
* @param scalar $index |
198
|
|
|
* @return void |
199
|
|
|
*/ |
200
|
|
|
public function unsetEndProperty($index) |
201
|
|
|
{ |
202
|
|
|
unset($this->endProperty[$index]); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Gets as endProperty |
207
|
|
|
* |
208
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType[] |
209
|
|
|
*/ |
210
|
|
|
public function getEndProperty() |
211
|
|
|
{ |
212
|
|
|
return $this->endProperty; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Sets a new endProperty |
217
|
|
|
* |
218
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType[] $endProperty |
219
|
|
|
* @return self |
220
|
|
|
*/ |
221
|
|
|
public function setEndProperty(array $endProperty) |
222
|
|
|
{ |
223
|
|
|
$msg = null; |
224
|
|
|
if (!$this->isValidArrayOK( |
225
|
|
|
$endProperty, |
226
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType', |
227
|
|
|
$msg, |
228
|
|
|
0, |
229
|
|
|
2 |
230
|
|
|
)) { |
231
|
|
|
throw new \InvalidArgumentException("End property array not a valid array, or has more than 2 elements"); |
232
|
|
|
} |
233
|
|
|
$this->endProperty = $endProperty; |
234
|
|
|
return $this; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Adds as condition |
239
|
|
|
* |
240
|
|
|
* @return self |
241
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition |
242
|
|
|
*/ |
243
|
|
View Code Duplication |
public function addToCondition(TConditionType $condition) |
|
|
|
|
244
|
|
|
{ |
245
|
|
|
$msg = null; |
246
|
|
|
if (!$condition->isOK($msg)) { |
247
|
|
|
throw new \InvalidArgumentException($msg); |
248
|
|
|
} |
249
|
|
|
$this->condition[] = $condition; |
250
|
|
|
return $this; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* isset condition |
255
|
|
|
* |
256
|
|
|
* @param scalar $index |
257
|
|
|
* @return boolean |
258
|
|
|
*/ |
259
|
|
|
public function issetCondition($index) |
260
|
|
|
{ |
261
|
|
|
return isset($this->condition[$index]); |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* unset condition |
266
|
|
|
* |
267
|
|
|
* @param scalar $index |
268
|
|
|
* @return void |
269
|
|
|
*/ |
270
|
|
|
public function unsetCondition($index) |
271
|
|
|
{ |
272
|
|
|
unset($this->condition[$index]); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* Gets as condition |
277
|
|
|
* |
278
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] |
279
|
|
|
*/ |
280
|
|
|
public function getCondition() |
281
|
|
|
{ |
282
|
|
|
return $this->condition; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* Sets a new condition |
287
|
|
|
* |
288
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] $condition |
289
|
|
|
* @return self |
290
|
|
|
*/ |
291
|
|
View Code Duplication |
public function setCondition(array $condition) |
|
|
|
|
292
|
|
|
{ |
293
|
|
|
$msg = null; |
294
|
|
|
if (!$this->isValidArrayOK( |
295
|
|
|
$condition, |
296
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType', |
297
|
|
|
$msg |
298
|
|
|
)) { |
299
|
|
|
throw new \InvalidArgumentException($msg); |
300
|
|
|
} |
301
|
|
|
$this->condition = $condition; |
302
|
|
|
return $this; |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Gets as modificationFunctionMapping |
307
|
|
|
* |
308
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetModificationFunctionMappingType |
309
|
|
|
*/ |
310
|
|
|
public function getModificationFunctionMapping() |
311
|
|
|
{ |
312
|
|
|
return $this->modificationFunctionMapping; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* Sets a new modificationFunctionMapping |
317
|
|
|
* |
318
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetModificationFunctionMappingType |
319
|
|
|
* $modificationFunctionMapping |
320
|
|
|
* @return self |
321
|
|
|
*/ |
322
|
|
|
public function setModificationFunctionMapping(TAssociationSetModificationFunctionMappingType $modificationFunctionMapping) |
323
|
|
|
{ |
324
|
|
|
$msg = null; |
325
|
|
|
if (!$modificationFunctionMapping->isOK($msg)) { |
326
|
|
|
throw new \InvalidArgumentException($msg); |
327
|
|
|
} |
328
|
|
|
$this->modificationFunctionMapping = $modificationFunctionMapping; |
329
|
|
|
return $this; |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
public function isOK(&$msg = null) |
333
|
|
|
{ |
334
|
|
|
if (!$this->isStringNotNullOrEmpty($this->name)) { |
335
|
|
|
$msg = 'Name cannot be null or empty'; |
336
|
|
|
return false; |
337
|
|
|
} |
338
|
|
View Code Duplication |
if (null != $this->typeName && !$this->isStringNotNullOrEmpty($this->typeName)) { |
|
|
|
|
339
|
|
|
$msg = 'Type name cannot be empty'; |
340
|
|
|
return false; |
341
|
|
|
} |
342
|
|
View Code Duplication |
if (null != $this->storeEntitySet && !$this->isStringNotNullOrEmpty($this->storeEntitySet)) { |
|
|
|
|
343
|
|
|
$msg = 'Store entity set cannot be empty'; |
344
|
|
|
return false; |
345
|
|
|
} |
346
|
|
|
if (null != $this->queryView && !$this->isStringNotNullOrEmpty($this->queryView)) { |
347
|
|
|
$msg = 'Query view cannot be empty'; |
348
|
|
|
return false; |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
if (!$this->isTSimpleIdentifierValid($this->name)) { |
352
|
|
|
$msg = 'Name must be a valid TSimpleIdentifier'; |
353
|
|
|
return false; |
354
|
|
|
} |
355
|
|
|
if (null != $this->typeName && !$this->isTQualifiedNameValid($this->typeName)) { |
356
|
|
|
$msg = 'Type name must be a valid TQualifiedName'; |
357
|
|
|
return false; |
358
|
|
|
} |
359
|
|
|
if (null != $this->modificationFunctionMapping && !$this->modificationFunctionMapping->isOK($msg)) { |
360
|
|
|
return false; |
361
|
|
|
} |
362
|
|
|
if (!$this->isValidArray( |
363
|
|
|
$this->endProperty, |
364
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEndPropertyType', |
365
|
|
|
0, |
366
|
|
|
2 |
367
|
|
|
)) { |
368
|
|
|
$msg = "End property array not a valid array, or has more than 2 elements"; |
369
|
|
|
return false; |
370
|
|
|
} |
371
|
|
|
if (!$this->isChildArrayOK($this->endProperty, $msg)) { |
372
|
|
|
return false; |
373
|
|
|
} |
374
|
|
|
if (!$this->isValidArray( |
375
|
|
|
$this->endProperty, |
376
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType' |
377
|
|
|
)) { |
378
|
|
|
$msg = "Condition array not a valid array"; |
379
|
|
|
return false; |
380
|
|
|
} |
381
|
|
|
if (!$this->isChildArrayOK($this->condition, $msg)) { |
382
|
|
|
return false; |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
return true; |
386
|
|
|
} |
387
|
|
|
} |
388
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.