1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV4\edmx; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV4\edm\Annotation; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class representing TReferenceType |
10
|
|
|
* |
11
|
|
|
* |
12
|
|
|
* XSD Type: TReference |
13
|
|
|
*/ |
14
|
|
|
class TReferenceType extends IsOK |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @property string $uri |
19
|
|
|
*/ |
20
|
|
|
private $uri = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeType[] $include |
24
|
|
|
*/ |
25
|
|
|
private $include = array(); |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeAnnotationsType[] $includeAnnotations |
29
|
|
|
*/ |
30
|
|
|
private $includeAnnotations = array(); |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV4\edm\Annotation[] $annotation |
34
|
|
|
*/ |
35
|
|
|
private $annotation = array(); |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Gets as uri |
39
|
|
|
* |
40
|
|
|
* @return string |
41
|
|
|
*/ |
42
|
|
|
public function getUri() |
43
|
|
|
{ |
44
|
|
|
return $this->uri; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Sets a new uri |
49
|
|
|
* |
50
|
|
|
* @param string $uri |
51
|
|
|
* @return self |
52
|
|
|
*/ |
53
|
|
|
public function setUri($uri) |
54
|
|
|
{ |
55
|
|
|
$this->uri = $uri; |
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Adds as include |
61
|
|
|
* |
62
|
|
|
* @return self |
63
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeType $include |
64
|
|
|
*/ |
65
|
|
|
public function addToInclude(TIncludeType $include) |
66
|
|
|
{ |
67
|
|
|
$this->include[] = $include; |
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* isset include |
73
|
|
|
* |
74
|
|
|
* @param scalar $index |
75
|
|
|
* @return boolean |
76
|
|
|
*/ |
77
|
|
|
public function issetInclude($index) |
78
|
|
|
{ |
79
|
|
|
return isset($this->include[$index]); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* unset include |
84
|
|
|
* |
85
|
|
|
* @param scalar $index |
86
|
|
|
* @return void |
87
|
|
|
*/ |
88
|
|
|
public function unsetInclude($index) |
89
|
|
|
{ |
90
|
|
|
unset($this->include[$index]); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Gets as include |
95
|
|
|
* |
96
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeType[] |
97
|
|
|
*/ |
98
|
|
|
public function getInclude() |
99
|
|
|
{ |
100
|
|
|
return $this->include; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Sets a new include |
105
|
|
|
* |
106
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeType[] $include |
107
|
|
|
* @return self |
108
|
|
|
*/ |
109
|
|
|
public function setInclude(array $include) |
110
|
|
|
{ |
111
|
|
|
$this->include = $include; |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Adds as includeAnnotations |
117
|
|
|
* |
118
|
|
|
* @return self |
119
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeAnnotationsType $includeAnnotations |
120
|
|
|
*/ |
121
|
|
|
public function addToIncludeAnnotations(TIncludeAnnotationsType $includeAnnotations) |
122
|
|
|
{ |
123
|
|
|
$this->includeAnnotations[] = $includeAnnotations; |
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* isset includeAnnotations |
129
|
|
|
* |
130
|
|
|
* @param scalar $index |
131
|
|
|
* @return boolean |
132
|
|
|
*/ |
133
|
|
|
public function issetIncludeAnnotations($index) |
134
|
|
|
{ |
135
|
|
|
return isset($this->includeAnnotations[$index]); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* unset includeAnnotations |
140
|
|
|
* |
141
|
|
|
* @param scalar $index |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
public function unsetIncludeAnnotations($index) |
145
|
|
|
{ |
146
|
|
|
unset($this->includeAnnotations[$index]); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Gets as includeAnnotations |
151
|
|
|
* |
152
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeAnnotationsType[] |
153
|
|
|
*/ |
154
|
|
|
public function getIncludeAnnotations() |
155
|
|
|
{ |
156
|
|
|
return $this->includeAnnotations; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Sets a new includeAnnotations |
161
|
|
|
* |
162
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeAnnotationsType[] $includeAnnotations |
163
|
|
|
* @return self |
164
|
|
|
*/ |
165
|
|
|
public function setIncludeAnnotations(array $includeAnnotations) |
166
|
|
|
{ |
167
|
|
|
$this->includeAnnotations = $includeAnnotations; |
168
|
|
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Adds as annotation |
173
|
|
|
* |
174
|
|
|
* @return self |
175
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edm\Annotation $annotation |
176
|
|
|
*/ |
177
|
|
|
public function addToAnnotation(Annotation $annotation) |
178
|
|
|
{ |
179
|
|
|
$this->annotation[] = $annotation; |
180
|
|
|
return $this; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* isset annotation |
185
|
|
|
* |
186
|
|
|
* @param scalar $index |
187
|
|
|
* @return boolean |
188
|
|
|
*/ |
189
|
|
|
public function issetAnnotation($index) |
190
|
|
|
{ |
191
|
|
|
return isset($this->annotation[$index]); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* unset annotation |
196
|
|
|
* |
197
|
|
|
* @param scalar $index |
198
|
|
|
* @return void |
199
|
|
|
*/ |
200
|
|
|
public function unsetAnnotation($index) |
201
|
|
|
{ |
202
|
|
|
unset($this->annotation[$index]); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Gets as annotation |
207
|
|
|
* |
208
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV4\edm\Annotation[] |
209
|
|
|
*/ |
210
|
|
|
public function getAnnotation() |
211
|
|
|
{ |
212
|
|
|
return $this->annotation; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Sets a new annotation |
217
|
|
|
* |
218
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV4\edm\Annotation[] $annotation |
219
|
|
|
* @return self |
220
|
|
|
*/ |
221
|
|
|
public function setAnnotation(array $annotation) |
222
|
|
|
{ |
223
|
|
|
$this->annotation = $annotation; |
224
|
|
|
return $this; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
protected function isOK(&$msg = null) |
228
|
|
|
{ |
229
|
|
|
if (!$this->isURLValid($this->uri)) { |
230
|
|
|
$msg = "Uri must be valid"; |
231
|
|
|
return false; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
if (!$this->isValidArray($this->include, \AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeType, 1)) { |
235
|
|
|
$msg = "Include is not a valid array"; |
236
|
|
|
return false; |
237
|
|
|
} |
238
|
|
|
if (!$this->isValidArray( |
239
|
|
|
$this->includeAnnotations, |
240
|
|
|
\AlgoWeb\ODataMetadata\MetadataV4\edmx\TIncludeAnnotationsType, |
241
|
|
|
1 |
242
|
|
|
)) { |
243
|
|
|
$msg = "IncludeAnnotations is not a valid array"; |
244
|
|
|
return false; |
245
|
|
|
} |
246
|
|
|
if (!$this->isValidArray($this->annotation, \AlgoWeb\ODataMetadata\MetadataV4\edm\Annotation, 1)) { |
247
|
|
|
$msg = "Annotation is not a valid array"; |
248
|
|
|
return false; |
249
|
|
|
} |
250
|
|
|
if (!$this->isChildArrayOK($this->include, $msg)) { |
251
|
|
|
return false; |
252
|
|
|
} |
253
|
|
|
if (!$this->isChildArrayOK($this->includeAnnotations, $msg)) { |
254
|
|
|
return false; |
255
|
|
|
} |
256
|
|
|
if (!$this->isChildArrayOK($this->annotation, $msg)) { |
257
|
|
|
return false; |
258
|
|
|
} |
259
|
|
|
return true; |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
|