1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\Groups; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TFunctionImportParameterAndReturnTypeTrait; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TMaxLengthFacetTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TParameterModeTrait; |
8
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TPrecisionFacetTrait; |
9
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TScaleFacetTrait; |
10
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait; |
11
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSridFacetTrait; |
12
|
|
|
|
13
|
|
|
trait TFunctionImportParameterAttributesTrait |
14
|
|
|
{ |
15
|
|
|
use TSimpleIdentifierTrait, TParameterModeTrait, TFunctionImportParameterAndReturnTypeTrait, TMaxLengthFacetTrait, |
16
|
|
|
TPrecisionFacetTrait, TScaleFacetTrait, TSridFacetTrait; |
17
|
|
|
|
18
|
|
|
/* |
19
|
|
|
* @property string $name |
20
|
|
|
*/ |
21
|
|
|
private $name = null; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @property string $type |
25
|
|
|
*/ |
26
|
|
|
private $type = null; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @property string $mode |
30
|
|
|
*/ |
31
|
|
|
private $mode = null; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @property string $maxLength |
35
|
|
|
*/ |
36
|
|
|
private $maxLength = null; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @property integer $precision |
40
|
|
|
*/ |
41
|
|
|
private $precision = null; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @property integer $scale |
45
|
|
|
*/ |
46
|
|
|
private $scale = null; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @property string $sRID |
50
|
|
|
*/ |
51
|
|
|
private $sRID = null; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Gets as name |
55
|
|
|
* |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
public function getName() |
59
|
|
|
{ |
60
|
|
|
return $this->name; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Sets a new name |
65
|
|
|
* |
66
|
|
|
* @param string $name |
67
|
|
|
* @return self |
68
|
|
|
*/ |
69
|
|
View Code Duplication |
public function setName($name) |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
$msg = null; |
|
|
|
|
72
|
|
|
if (!$this->isTSimpleIdentifierValid($name)) { |
73
|
|
|
$msg = "Name must be a valid TSimpleIdentifier"; |
74
|
|
|
throw new \InvalidArgumentException($msg); |
75
|
|
|
} |
76
|
|
|
$this->name = $name; |
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Gets as type |
82
|
|
|
* |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
public function getType() |
86
|
|
|
{ |
87
|
|
|
return $this->type; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Sets a new type |
92
|
|
|
* |
93
|
|
|
* @param string $type |
94
|
|
|
* @return self |
95
|
|
|
*/ |
96
|
|
|
public function setType($type) |
97
|
|
|
{ |
98
|
|
|
$msg = null; |
|
|
|
|
99
|
|
|
if (!$this->isTFunctionImportParameterAndReturnTypeValid($type)) { |
100
|
|
|
$msg = "Type must be a valid TFunctionImportParameterAndReturnType"; |
101
|
|
|
throw new \InvalidArgumentException($msg); |
102
|
|
|
} |
103
|
|
|
$this->type = $type; |
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Gets as mode |
109
|
|
|
* |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
public function getMode() |
113
|
|
|
{ |
114
|
|
|
return $this->mode; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Sets a new mode |
119
|
|
|
* |
120
|
|
|
* @param string $mode |
121
|
|
|
* @return self |
122
|
|
|
*/ |
123
|
|
|
public function setMode($mode) |
124
|
|
|
{ |
125
|
|
|
$msg = null; |
|
|
|
|
126
|
|
View Code Duplication |
if (null != $mode && !$this->isTParameterModeValid($mode)) { |
|
|
|
|
127
|
|
|
$msg = "Mode must be a valid TParameterMode"; |
128
|
|
|
throw new \InvalidArgumentException($msg); |
129
|
|
|
} |
130
|
|
|
$this->mode = $mode; |
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Gets as maxLength |
136
|
|
|
* |
137
|
|
|
* @return string |
138
|
|
|
*/ |
139
|
|
|
public function getMaxLength() |
140
|
|
|
{ |
141
|
|
|
return $this->maxLength; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Sets a new maxLength |
146
|
|
|
* |
147
|
|
|
* @param string $maxLength |
148
|
|
|
* @return self |
149
|
|
|
*/ |
150
|
|
View Code Duplication |
public function setMaxLength($maxLength) |
|
|
|
|
151
|
|
|
{ |
152
|
|
|
$msg = null; |
|
|
|
|
153
|
|
|
if (null != $maxLength && !$this->isTMaxLengthFacetValid($maxLength)) { |
154
|
|
|
$msg = "Max length must be a valid TMaxLengthFacet"; |
155
|
|
|
throw new \InvalidArgumentException($msg); |
156
|
|
|
} |
157
|
|
|
$this->maxLength = $maxLength; |
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Gets as precision |
163
|
|
|
* |
164
|
|
|
* @return integer |
165
|
|
|
*/ |
166
|
|
|
public function getPrecision() |
167
|
|
|
{ |
168
|
|
|
return $this->precision; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Sets a new precision |
173
|
|
|
* |
174
|
|
|
* @param integer $precision |
175
|
|
|
* @return self |
176
|
|
|
*/ |
177
|
|
View Code Duplication |
public function setPrecision($precision) |
|
|
|
|
178
|
|
|
{ |
179
|
|
|
$msg = null; |
|
|
|
|
180
|
|
|
if (null != $precision && !$this->isTPrecisionFacetValid($precision)) { |
181
|
|
|
$msg = "Precision must be a valid TPrecisionFacet"; |
182
|
|
|
throw new \InvalidArgumentException($msg); |
183
|
|
|
} |
184
|
|
|
$this->precision = $precision; |
185
|
|
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* Gets as scale |
190
|
|
|
* |
191
|
|
|
* @return integer |
192
|
|
|
*/ |
193
|
|
|
public function getScale() |
194
|
|
|
{ |
195
|
|
|
return $this->scale; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Sets a new scale |
200
|
|
|
* |
201
|
|
|
* @param integer $scale |
202
|
|
|
* @return self |
203
|
|
|
*/ |
204
|
|
View Code Duplication |
public function setScale($scale) |
|
|
|
|
205
|
|
|
{ |
206
|
|
|
$msg = null; |
|
|
|
|
207
|
|
|
if (null != $scale && !$this->isTScaleFacetValid($scale)) { |
208
|
|
|
$msg = "Scale must be a valid TScaleFacet"; |
209
|
|
|
throw new \InvalidArgumentException($msg); |
210
|
|
|
} |
211
|
|
|
$this->scale = $scale; |
212
|
|
|
return $this; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Gets as sRID |
217
|
|
|
* |
218
|
|
|
* @return string |
219
|
|
|
*/ |
220
|
|
|
public function getSRID() |
221
|
|
|
{ |
222
|
|
|
return $this->sRID; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Sets a new sRID |
227
|
|
|
* |
228
|
|
|
* @param string $sRID |
229
|
|
|
* @return self |
230
|
|
|
*/ |
231
|
|
View Code Duplication |
public function setSRID($sRID) |
|
|
|
|
232
|
|
|
{ |
233
|
|
|
$msg = null; |
|
|
|
|
234
|
|
|
if (null != $sRID && !$this->isTSridFacetValid($sRID)) { |
235
|
|
|
$msg = "SRID must be a valid TSRIDFacet"; |
236
|
|
|
throw new \InvalidArgumentException($msg); |
237
|
|
|
} |
238
|
|
|
$this->sRID = $sRID; |
239
|
|
|
return $this; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
public function isTFunctionImportParameterAttributesValid(&$msg = null) |
243
|
|
|
{ |
244
|
|
|
if (!$this->isTSimpleIdentifierValid($this->name)) { |
245
|
|
|
$msg = "Name must be a valid TSimpleIdentifier"; |
246
|
|
|
return false; |
247
|
|
|
} |
248
|
|
|
if (!$this->isTFunctionImportParameterAndReturnTypeValid($this->type)) { |
249
|
|
|
$msg = "Type must be a valid TFunctionImportParameterAndReturnType"; |
250
|
|
|
return false; |
251
|
|
|
} |
252
|
|
View Code Duplication |
if (null != $this->mode && !$this->isTParameterModeValid($this->mode)) { |
|
|
|
|
253
|
|
|
$msg = "Mode must be a valid TParameterMode"; |
254
|
|
|
return false; |
255
|
|
|
} |
256
|
|
View Code Duplication |
if (null != $this->maxLength && !$this->isTMaxLengthFacetValid($this->maxLength)) { |
|
|
|
|
257
|
|
|
$msg = "Max length must be a valid TMaxLengthFacet"; |
258
|
|
|
return false; |
259
|
|
|
} |
260
|
|
View Code Duplication |
if (null != $this->precision && !$this->isTPrecisionFacetValid($this->precision)) { |
|
|
|
|
261
|
|
|
$msg = "Precision must be a valid TPrecisionFacet"; |
262
|
|
|
return false; |
263
|
|
|
} |
264
|
|
View Code Duplication |
if (null != $this->scale && !$this->isTScaleFacetValid($this->scale)) { |
|
|
|
|
265
|
|
|
$msg = "Scale must be a valid TScaleFacet"; |
266
|
|
|
return false; |
267
|
|
|
} |
268
|
|
View Code Duplication |
if (null != $this->sRID && !$this->isTSridFacetValid($this->sRID)) { |
|
|
|
|
269
|
|
|
$msg = "SRID must be a valid TSRIDFacet"; |
270
|
|
|
return false; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
return true; |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
|
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.