1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\CodeGeneration\AccessTypeTraits; |
6
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
7
|
|
|
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\Groups\GEmptyElementExtensibilityTrait; |
9
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TQualifiedNameTrait; |
10
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class representing TNavigationPropertyType |
14
|
|
|
* |
15
|
|
|
* |
16
|
|
|
* XSD Type: TNavigationProperty |
17
|
|
|
*/ |
18
|
|
|
class TNavigationPropertyType extends IsOK |
19
|
|
|
{ |
20
|
|
|
use IsOKToolboxTrait, |
21
|
|
|
GEmptyElementExtensibilityTrait, |
22
|
|
|
TQualifiedNameTrait, |
23
|
|
|
TSimpleIdentifierTrait, |
24
|
|
|
AccessTypeTraits; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @property string $name |
28
|
|
|
*/ |
29
|
|
|
private $name = null; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @property string $relationship |
33
|
|
|
*/ |
34
|
|
|
private $relationship = null; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @property string $toRole |
38
|
|
|
*/ |
39
|
|
|
private $toRole = null; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @property string $fromRole |
43
|
|
|
*/ |
44
|
|
|
private $fromRole = null; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @property string $getterAccess |
48
|
|
|
*/ |
49
|
|
|
private $getterAccess = null; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @property string $setterAccess |
53
|
|
|
*/ |
54
|
|
|
private $setterAccess = null; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Gets as name |
58
|
|
|
* |
59
|
|
|
* @return string |
60
|
|
|
*/ |
61
|
|
|
public function getName() |
62
|
|
|
{ |
63
|
|
|
return $this->name; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Sets a new name |
68
|
|
|
* |
69
|
|
|
* @param string $name |
70
|
|
|
* @return self |
71
|
|
|
*/ |
72
|
|
|
public function setName($name) |
73
|
|
|
{ |
74
|
|
|
$this->name = $name; |
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Gets as relationship |
80
|
|
|
* |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
|
|
public function getRelationship() |
84
|
|
|
{ |
85
|
|
|
return $this->relationship; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Sets a new relationship |
90
|
|
|
* |
91
|
|
|
* @param string $relationship |
92
|
|
|
* @return self |
93
|
|
|
*/ |
94
|
|
|
public function setRelationship($relationship) |
95
|
|
|
{ |
96
|
|
|
$this->relationship = $relationship; |
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Gets as toRole |
102
|
|
|
* |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function getToRole() |
106
|
|
|
{ |
107
|
|
|
return $this->toRole; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Sets a new toRole |
112
|
|
|
* |
113
|
|
|
* @param string $toRole |
114
|
|
|
* @return self |
115
|
|
|
*/ |
116
|
|
|
public function setToRole($toRole) |
117
|
|
|
{ |
118
|
|
|
$this->toRole = $toRole; |
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Gets as fromRole |
124
|
|
|
* |
125
|
|
|
* @return string |
126
|
|
|
*/ |
127
|
|
|
public function getFromRole() |
128
|
|
|
{ |
129
|
|
|
return $this->fromRole; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Sets a new fromRole |
134
|
|
|
* |
135
|
|
|
* @param string $fromRole |
136
|
|
|
* @return self |
137
|
|
|
*/ |
138
|
|
|
public function setFromRole($fromRole) |
139
|
|
|
{ |
140
|
|
|
$this->fromRole = $fromRole; |
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Gets as getterAccess |
146
|
|
|
* |
147
|
|
|
* @return string |
148
|
|
|
*/ |
149
|
|
|
public function getGetterAccess() |
150
|
|
|
{ |
151
|
|
|
return $this->getterAccess; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Sets a new getterAccess |
156
|
|
|
* |
157
|
|
|
* @param string $getterAccess |
158
|
|
|
* @return self |
159
|
|
|
*/ |
160
|
|
|
public function setGetterAccess($getterAccess) |
161
|
|
|
{ |
162
|
|
|
$this->getterAccess = $getterAccess; |
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Gets as setterAccess |
168
|
|
|
* |
169
|
|
|
* @return string |
170
|
|
|
*/ |
171
|
|
|
public function getSetterAccess() |
172
|
|
|
{ |
173
|
|
|
return $this->setterAccess; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Sets a new setterAccess |
178
|
|
|
* |
179
|
|
|
* @param string $setterAccess |
180
|
|
|
* @return self |
181
|
|
|
*/ |
182
|
|
|
public function setSetterAccess($setterAccess) |
183
|
|
|
{ |
184
|
|
|
$this->setterAccess = $setterAccess; |
185
|
|
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
public function isOK(&$msg = null) |
189
|
|
|
{ |
190
|
|
|
if (!$this->isTSimpleIdentifierValid($this->name)) { |
191
|
|
|
$msg = "Name must be a valid TSimpleIdentifier"; |
192
|
|
|
return false; |
193
|
|
|
} |
194
|
|
|
if (!$this->isTQualifiedNameValid($this->relationship)) { |
195
|
|
|
$msg = "Relationship must be a valid TQualifiedName"; |
196
|
|
|
return false; |
197
|
|
|
} |
198
|
|
|
if (!$this->isTSimpleIdentifierValid($this->toRole)) { |
199
|
|
|
$msg = "To role must be a valid TSimpleIdentifier"; |
200
|
|
|
return false; |
201
|
|
|
} |
202
|
|
|
if (!$this->isTSimpleIdentifierValid($this->fromRole)) { |
203
|
|
|
$msg = "From role must be a valid TSimpleIdentifier"; |
204
|
|
|
return false; |
205
|
|
|
} |
206
|
|
View Code Duplication |
if (null != $this->getterAccess && !$this->isTAccessOk($this->getterAccess)) { |
|
|
|
|
207
|
|
|
$msg = "Getter access must be a valid TAccess"; |
208
|
|
|
return false; |
209
|
|
|
} |
210
|
|
View Code Duplication |
if (null != $this->setterAccess && !$this->isTAccessOk($this->setterAccess)) { |
|
|
|
|
211
|
|
|
$msg = "Setter access must be a valid TAccess"; |
212
|
|
|
return false; |
213
|
|
|
} |
214
|
|
|
if (!$this->isExtensibilityElementOK($msg)) { |
215
|
|
|
return false; |
216
|
|
|
} |
217
|
|
|
return true; |
218
|
|
|
} |
219
|
|
|
} |
220
|
|
|
|
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.