1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\AssociationSetAnonymousType; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\EntitySetAnonymousType; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TUndottedIdentifierTrait; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class representing EntityContainer |
12
|
|
|
*/ |
13
|
|
|
class EntityContainer extends IsOK |
14
|
|
|
{ |
15
|
|
|
use TUndottedIdentifierTrait; |
16
|
|
|
/** |
17
|
|
|
* @property string $name |
18
|
|
|
*/ |
19
|
|
|
private $name = null; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
23
|
|
|
*/ |
24
|
|
|
private $documentation = null; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\EntitySetAnonymousType[] |
28
|
|
|
* $entitySet |
29
|
|
|
*/ |
30
|
|
|
private $entitySet = []; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\AssociationSetAnonymousType[] |
34
|
|
|
* $associationSet |
35
|
|
|
*/ |
36
|
|
|
private $associationSet = []; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Gets as name |
40
|
|
|
* |
41
|
|
|
* @return string |
42
|
|
|
*/ |
43
|
|
|
public function getName() |
44
|
|
|
{ |
45
|
|
|
return $this->name; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Sets a new name |
50
|
|
|
* |
51
|
|
|
* @param string $name |
52
|
|
|
* @return self |
53
|
|
|
*/ |
54
|
|
|
public function setName($name) |
55
|
|
|
{ |
56
|
|
|
$this->name = $name; |
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Gets as documentation |
62
|
|
|
* |
63
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType |
64
|
|
|
*/ |
65
|
|
|
public function getDocumentation() |
66
|
|
|
{ |
67
|
|
|
return $this->documentation; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Sets a new documentation |
72
|
|
|
* |
73
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
74
|
|
|
* @return self |
75
|
|
|
*/ |
76
|
|
|
public function setDocumentation(TDocumentationType $documentation) |
77
|
|
|
{ |
78
|
|
|
$msg = null; |
79
|
|
|
if (!$documentation->isOK($msg)) { |
80
|
|
|
throw new \InvalidArgumentException($msg); |
81
|
|
|
} |
82
|
|
|
$this->documentation = $documentation; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Adds as entitySet |
88
|
|
|
* |
89
|
|
|
* @return self |
90
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\EntitySetAnonymousType $entitySet |
91
|
|
|
*/ |
92
|
|
|
public function addToEntitySet(EntitySetAnonymousType $entitySet) |
93
|
|
|
{ |
94
|
|
|
$this->entitySet[] = $entitySet; |
95
|
|
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* isset entitySet |
100
|
|
|
* |
101
|
|
|
* @param scalar $index |
102
|
|
|
* @return boolean |
103
|
|
|
*/ |
104
|
|
|
public function issetEntitySet($index) |
105
|
|
|
{ |
106
|
|
|
return isset($this->entitySet[$index]); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* unset entitySet |
111
|
|
|
* |
112
|
|
|
* @param scalar $index |
113
|
|
|
* @return void |
114
|
|
|
*/ |
115
|
|
|
public function unsetEntitySet($index) |
116
|
|
|
{ |
117
|
|
|
unset($this->entitySet[$index]); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Gets as entitySet |
122
|
|
|
* |
123
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\EntitySetAnonymousType[] |
124
|
|
|
*/ |
125
|
|
|
public function getEntitySet() |
126
|
|
|
{ |
127
|
|
|
return $this->entitySet; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Sets a new entitySet |
132
|
|
|
* |
133
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\EntitySetAnonymousType[] $entitySet |
134
|
|
|
* @return self |
135
|
|
|
*/ |
136
|
|
|
public function setEntitySet(array $entitySet) |
137
|
|
|
{ |
138
|
|
|
$this->entitySet = $entitySet; |
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Adds as associationSet |
144
|
|
|
* |
145
|
|
|
* @return self |
146
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\AssociationSetAnonymousType |
147
|
|
|
* $associationSet |
148
|
|
|
*/ |
149
|
|
|
public function addToAssociationSet(AssociationSetAnonymousType $associationSet) |
150
|
|
|
{ |
151
|
|
|
$msg = null; |
152
|
|
|
if (!$associationSet->isOK($msg)) { |
153
|
|
|
throw new \InvalidArgumentException($msg); |
154
|
|
|
} |
155
|
|
|
$this->associationSet[] = $associationSet; |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* isset associationSet |
161
|
|
|
* |
162
|
|
|
* @param scalar $index |
163
|
|
|
* @return boolean |
164
|
|
|
*/ |
165
|
|
|
public function issetAssociationSet($index) |
166
|
|
|
{ |
167
|
|
|
return isset($this->associationSet[$index]); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* unset associationSet |
172
|
|
|
* |
173
|
|
|
* @param scalar $index |
174
|
|
|
* @return void |
175
|
|
|
*/ |
176
|
|
|
public function unsetAssociationSet($index) |
177
|
|
|
{ |
178
|
|
|
unset($this->associationSet[$index]); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Gets as associationSet |
183
|
|
|
* |
184
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\AssociationSetAnonymousType[] |
185
|
|
|
*/ |
186
|
|
|
public function getAssociationSet() |
187
|
|
|
{ |
188
|
|
|
return $this->associationSet; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Sets a new associationSet |
193
|
|
|
* |
194
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\AssociationSetAnonymousType[] |
195
|
|
|
* $associationSet |
196
|
|
|
* @return self |
197
|
|
|
*/ |
198
|
|
|
public function setAssociationSet(array $associationSet) |
199
|
|
|
{ |
200
|
|
|
$this->associationSet = $associationSet; |
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
View Code Duplication |
public function isOK(&$msg = null) |
|
|
|
|
205
|
|
|
{ |
206
|
|
|
if (!$this->isStringNotNullOrEmpty($this->name)) { |
207
|
|
|
$msg = "Name cannot be null or empty"; |
208
|
|
|
return false; |
209
|
|
|
} |
210
|
|
|
if (!$this->isTUndottedIdentifierValid($this->name)) { |
211
|
|
|
$msg = "Name must be a valid TUndottedIdentifier"; |
212
|
|
|
return false; |
213
|
|
|
} |
214
|
|
|
if (!$this->isObjectNullOrType( |
215
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType', |
216
|
|
|
$this->documentation, |
217
|
|
|
$msg |
218
|
|
|
)) { |
219
|
|
|
return false; |
220
|
|
|
} |
221
|
|
|
if (!$this->isValidArrayOK( |
222
|
|
|
$this->entitySet, |
223
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\EntitySetAnonymousType', |
224
|
|
|
$msg |
225
|
|
|
)) { |
226
|
|
|
return false; |
227
|
|
|
} |
228
|
|
|
if (!$this->isValidArrayOK( |
229
|
|
|
$this->associationSet, |
230
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer\AssociationSetAnonymousType', |
231
|
|
|
$msg |
232
|
|
|
)) { |
233
|
|
|
return false; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
return true; |
237
|
|
|
} |
238
|
|
|
} |
239
|
|
|
|
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.