1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TMultiplicityTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TQualifiedNameTrait; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TSimpleIdentifierTrait; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class representing TAssociationEndType |
12
|
|
|
* |
13
|
|
|
* |
14
|
|
|
* XSD Type: TAssociationEnd |
15
|
|
|
*/ |
16
|
|
|
class TAssociationEndType extends IsOK |
17
|
|
|
{ |
18
|
|
|
use TSimpleIdentifierTrait, TQualifiedNameTrait, TMultiplicityTrait, TOperations; |
19
|
|
|
/** |
20
|
|
|
* @property string $type |
21
|
|
|
*/ |
22
|
|
|
private $type = null; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @property string $role |
26
|
|
|
*/ |
27
|
|
|
private $role = null; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @property string $multiplicity |
31
|
|
|
*/ |
32
|
|
|
private $multiplicity = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
36
|
|
|
*/ |
37
|
|
|
private $documentation = null; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Gets as type |
41
|
|
|
* |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function getType() |
45
|
|
|
{ |
46
|
|
|
return $this->type; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Sets a new type |
51
|
|
|
* |
52
|
|
|
* @param string $type |
53
|
|
|
* @return self |
54
|
|
|
*/ |
55
|
|
|
public function setType($type) |
56
|
|
|
{ |
57
|
|
|
if (!$this->isStringNotNullOrEmpty($type)) { |
58
|
|
|
$msg = "Type cannot be null or empty"; |
59
|
|
|
throw new \InvalidArgumentException($msg); |
60
|
|
|
} |
61
|
|
|
$this->type = $type; |
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Gets as role |
67
|
|
|
* |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
public function getRole() |
71
|
|
|
{ |
72
|
|
|
return $this->role; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Sets a new role |
77
|
|
|
* |
78
|
|
|
* @param string $role |
79
|
|
|
* @return self |
80
|
|
|
*/ |
81
|
|
|
public function setRole($role) |
82
|
|
|
{ |
83
|
|
|
if (null != $role && !$this->isStringNotNullOrEmpty($role)) { |
84
|
|
|
$msg = "Role cannot be empty"; |
85
|
|
|
throw new \InvalidArgumentException($msg); |
86
|
|
|
} |
87
|
|
|
if (null != $role && !$this->isTSimpleIdentifierValid($role)) { |
88
|
|
|
$msg = "Role must be a valid TSimpleIdentifier"; |
89
|
|
|
throw new \InvalidArgumentException($msg); |
90
|
|
|
} |
91
|
|
|
$this->role = $role; |
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Gets as multiplicity |
97
|
|
|
* |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
|
|
public function getMultiplicity() |
101
|
|
|
{ |
102
|
|
|
return $this->multiplicity; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Sets a new multiplicity |
107
|
|
|
* |
108
|
|
|
* @param string $multiplicity |
109
|
|
|
* @return self |
110
|
|
|
*/ |
111
|
|
View Code Duplication |
public function setMultiplicity($multiplicity) |
|
|
|
|
112
|
|
|
{ |
113
|
|
|
$msg = null; |
|
|
|
|
114
|
|
|
if (!$this->isStringNotNullOrEmpty($multiplicity)) { |
115
|
|
|
$msg = "Multiplicity cannot be null or empty"; |
116
|
|
|
throw new \InvalidArgumentException($msg); |
117
|
|
|
} |
118
|
|
|
if (!$this->isTMultiplicityValid($multiplicity)) { |
119
|
|
|
$msg = "Multiplicity must be a valid TMultiplicity"; |
120
|
|
|
throw new \InvalidArgumentException($msg); |
121
|
|
|
} |
122
|
|
|
$this->multiplicity = $multiplicity; |
123
|
|
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Gets as documentation |
128
|
|
|
* |
129
|
|
|
* @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType |
130
|
|
|
*/ |
131
|
|
|
public function getDocumentation() |
132
|
|
|
{ |
133
|
|
|
return $this->documentation; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Sets a new documentation |
138
|
|
|
* |
139
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
140
|
|
|
* @return self |
141
|
|
|
*/ |
142
|
|
View Code Duplication |
public function setDocumentation(TDocumentationType $documentation) |
|
|
|
|
143
|
|
|
{ |
144
|
|
|
$msg = null; |
145
|
|
|
if (!$documentation->isOK($msg)) { |
146
|
|
|
throw new \InvalidArgumentException($msg); |
147
|
|
|
} |
148
|
|
|
$this->documentation = $documentation; |
149
|
|
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function isOK(&$msg = null) |
153
|
|
|
{ |
154
|
|
|
if (!$this->isStringNotNullOrEmpty($this->type)) { |
155
|
|
|
$msg = "Type cannot be null or empty"; |
156
|
|
|
return false; |
157
|
|
|
} |
158
|
|
|
if (!$this->isStringNotNullOrEmpty($this->multiplicity)) { |
159
|
|
|
$msg = "Multiplicity cannot be null or empty"; |
160
|
|
|
return false; |
161
|
|
|
} |
162
|
|
View Code Duplication |
if (null != $this->role && !$this->isStringNotNullOrEmpty($this->role)) { |
|
|
|
|
163
|
|
|
$msg = "Role cannot be empty"; |
164
|
|
|
return false; |
165
|
|
|
} |
166
|
|
|
if (null != $this->role && !$this->isTSimpleIdentifierValid($this->role)) { |
167
|
|
|
$msg = "Role must be a valid TSimpleIdentifier"; |
168
|
|
|
return false; |
169
|
|
|
} |
170
|
|
|
if (!$this->isTMultiplicityValid($this->multiplicity)) { |
171
|
|
|
$msg = "Multiplicity must be a valid TMultiplicity"; |
172
|
|
|
return false; |
173
|
|
|
} |
174
|
|
|
if (!$this->isOperationsGroupOK($msg)) { |
175
|
|
|
return false; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
return true; |
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
|
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.