Passed
Push — master ( 46bec3...dbfdbf )
by Alex
04:19
created

TEntityPropertyType::setDocumentation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TPropertyTypeTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TSimpleIdentifierTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TStoreGeneratedPatternTrait;
9
10
/**
11
 * Class representing TEntityPropertyType
12
 *
13
 *
14
 * XSD Type: TEntityProperty
15
 */
16
class TEntityPropertyType extends IsOK
17
{
18
    use TSimpleIdentifierTrait, TPropertyTypeTrait, TStoreGeneratedPatternTrait, GEmptyElementExtensibilityTrait;
19
    /**
20
     * @property string $name
21
     */
22
    private $name = null;
23
24
    /**
25
     * @property string $type
26
     */
27
    private $type = null;
28
29
    /**
30
     * @property boolean $nullable
31
     */
32
    private $nullable = true;
33
34
    /**
35
     * @property string $defaultValue
36
     */
37
    private $defaultValue = null;
38
39
    /**
40
     * @property string $maxLength
41
     */
42
    private $maxLength = null;
43
44
    /**
45
     * @property boolean $fixedLength
46
     */
47
    private $fixedLength = null;
48
49
    /**
50
     * @property integer $precision
51
     */
52
    private $precision = null;
53
54
    /**
55
     * @property integer $scale
56
     */
57
    private $scale = null;
58
59
    /**
60
     * @property boolean $unicode
61
     */
62
    private $unicode = null;
63
64
    /**
65
     * @property string $collation
66
     */
67
    private $collation = null;
68
69
    /**
70
     * @property string $sRID
71
     */
72
    private $sRID = null;
73
74
    /**
75
     * @property string $storeGeneratedPattern
76
     */
77
    private $storeGeneratedPattern = null;
78
79
    /**
80
     * Gets as name
81
     *
82
     * @return string
83
     */
84
    public function getName()
85
    {
86
        return $this->name;
87
    }
88
89
    /**
90
     * Sets a new name
91
     *
92
     * @param string $name
93
     * @return self
94
     */
95
    public function setName($name)
96
    {
97
        $this->name = $name;
98
        return $this;
99
    }
100
101
    /**
102
     * Gets as type
103
     *
104
     * @return string
105
     */
106
    public function getType()
107
    {
108
        return $this->type;
109
    }
110
111
    /**
112
     * Sets a new type
113
     *
114
     * @param string $type
115
     * @return self
116
     */
117
    public function setType($type)
118
    {
119
        $this->type = $type;
120
        return $this;
121
    }
122
123
    /**
124
     * Gets as nullable
125
     *
126
     * @return boolean
127
     */
128
    public function getNullable()
129
    {
130
        return $this->nullable;
131
    }
132
133
    /**
134
     * Sets a new nullable
135
     *
136
     * @param boolean $nullable
137
     * @return self
138
     */
139
    public function setNullable($nullable)
140
    {
141
        $this->nullable = $nullable;
142
        return $this;
143
    }
144
145
    /**
146
     * Gets as defaultValue
147
     *
148
     * @return string
149
     */
150
    public function getDefaultValue()
151
    {
152
        return $this->defaultValue;
153
    }
154
155
    /**
156
     * Sets a new defaultValue
157
     *
158
     * @param string $defaultValue
159
     * @return self
160
     */
161
    public function setDefaultValue($defaultValue)
162
    {
163
        $this->defaultValue = $defaultValue;
164
        return $this;
165
    }
166
167
    /**
168
     * Gets as maxLength
169
     *
170
     * @return string
171
     */
172
    public function getMaxLength()
173
    {
174
        return $this->maxLength;
175
    }
176
177
    /**
178
     * Sets a new maxLength
179
     *
180
     * @param string $maxLength
181
     * @return self
182
     */
183
    public function setMaxLength($maxLength)
184
    {
185
        $this->maxLength = $maxLength;
186
        return $this;
187
    }
188
189
    /**
190
     * Gets as fixedLength
191
     *
192
     * @return boolean
193
     */
194
    public function getFixedLength()
195
    {
196
        return $this->fixedLength;
197
    }
198
199
    /**
200
     * Sets a new fixedLength
201
     *
202
     * @param boolean $fixedLength
203
     * @return self
204
     */
205
    public function setFixedLength($fixedLength)
206
    {
207
        $this->fixedLength = $fixedLength;
208
        return $this;
209
    }
210
211
    /**
212
     * Gets as precision
213
     *
214
     * @return integer
215
     */
216
    public function getPrecision()
217
    {
218
        return $this->precision;
219
    }
220
221
    /**
222
     * Sets a new precision
223
     *
224
     * @param integer $precision
225
     * @return self
226
     */
227
    public function setPrecision($precision)
228
    {
229
        $this->precision = $precision;
230
        return $this;
231
    }
232
233
    /**
234
     * Gets as scale
235
     *
236
     * @return integer
237
     */
238
    public function getScale()
239
    {
240
        return $this->scale;
241
    }
242
243
    /**
244
     * Sets a new scale
245
     *
246
     * @param integer $scale
247
     * @return self
248
     */
249
    public function setScale($scale)
250
    {
251
        $this->scale = $scale;
252
        return $this;
253
    }
254
255
    /**
256
     * Gets as unicode
257
     *
258
     * @return boolean
259
     */
260
    public function getUnicode()
261
    {
262
        return $this->unicode;
263
    }
264
265
    /**
266
     * Sets a new unicode
267
     *
268
     * @param boolean $unicode
269
     * @return self
270
     */
271
    public function setUnicode($unicode)
272
    {
273
        $this->unicode = $unicode;
274
        return $this;
275
    }
276
277
    /**
278
     * Gets as collation
279
     *
280
     * @return string
281
     */
282
    public function getCollation()
283
    {
284
        return $this->collation;
285
    }
286
287
    /**
288
     * Sets a new collation
289
     *
290
     * @param string $collation
291
     * @return self
292
     */
293
    public function setCollation($collation)
294
    {
295
        $this->collation = $collation;
296
        return $this;
297
    }
298
299
    /**
300
     * Gets as sRID
301
     *
302
     * @return string
303
     */
304
    public function getSRID()
305
    {
306
        return $this->sRID;
307
    }
308
309
    /**
310
     * Sets a new sRID
311
     *
312
     * @param string $sRID
313
     * @return self
314
     */
315
    public function setSRID($sRID)
316
    {
317
        $this->sRID = $sRID;
318
        return $this;
319
    }
320
321
    /**
322
     * Gets as storeGeneratedPattern
323
     *
324
     * @return string
325
     */
326
    public function getStoreGeneratedPattern()
327
    {
328
        return $this->storeGeneratedPattern;
329
    }
330
331
    /**
332
     * Sets a new storeGeneratedPattern
333
     *
334
     * @param string $storeGeneratedPattern
335
     * @return self
336
     */
337
    public function setStoreGeneratedPattern($storeGeneratedPattern)
338
    {
339
        $this->storeGeneratedPattern = $storeGeneratedPattern;
340
        return $this;
341
    }
342
343
    public function isOK(&$msg = null)
344
    {
345
        if (!$this->isStringNotNullOrEmpty($this->name)) {
346
            $msg = "Name cannot be null or empty";
347
            return false;
348
        }
349
        if (!$this->isStringNotNullOrEmpty($this->type)) {
350
            $msg = "Type cannot be null or empty";
351
            return false;
352
        }
353 View Code Duplication
        if (null != $this->defaultValue && !$this->isStringNotNullOrEmpty($this->defaultValue)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
354
            $msg = "Default value cannot be empty";
355
            return false;
356
        }
357 View Code Duplication
        if (null != $this->maxLength && !(is_numeric($this->maxLength) && 0 < $this->maxLength)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
358
            $msg = "Max length must be positive and numeric";
359
            return false;
360
        }
361 View Code Duplication
        if (null != $this->precision && !(is_numeric($this->precision) && 0 < $this->precision)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
362
            $msg = "Precision must be positive and numeric";
363
            return false;
364
        }
365 View Code Duplication
        if (null != $this->scale && !(is_numeric($this->scale) && 0 < $this->scale)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
366
            $msg = "Scale must be positive and numeric";
367
            return false;
368
        }
369 View Code Duplication
        if (null != $this->collation && !$this->isStringNotNullOrEmpty($this->collation)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
370
            $msg = "Collation cannot be empty";
371
            return false;
372
        }
373 View Code Duplication
        if (null != $this->sRID && !$this->isStringNotNullOrEmpty($this->sRID)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
374
            $msg = "SRID cannot be empty";
375
            return false;
376
        }
377
        if (null != $this->storeGeneratedPattern && !$this->isStringNotNullOrEmpty($this->storeGeneratedPattern)) {
378
            $msg = "Store generated pattern cannot be empty";
379
            return false;
380
        }
381
382
        if (!$this->isTSimpleIdentifierValid($this->name)) {
383
            $msg = "Name must be valid TSimpleIdentifier";
384
            return false;
385
        }
386
        if (!$this->isTPropertyTypeValid($this->type)) {
387
            $msg = "Type must be valid TPropertyType";
388
            return false;
389
        }
390
        if (null != $this->storeGeneratedPattern
391
            && !$this->isTStoreGeneratedPatternValid($this->storeGeneratedPattern)) {
392
            $msg = "Store generated pattern must be valid TStoreGeneratedPattern";
393
            return false;
394
        }
395
        if (!$this->isExtensibilityElementOK($msg)) {
396
            return false;
397
        }
398
399
        return true;
400
    }
401
}
402