Passed
Push — master ( d2da49...fac384 )
by Alex
03:51
created

TEntityPropertyType::setDefaultValue()   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;
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
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
81
     */
82
    private $documentation = null;
83
84
    /**
85
     * Gets as name
86
     *
87
     * @return string
88
     */
89
    public function getName()
90
    {
91
        return $this->name;
92
    }
93
94
    /**
95
     * Sets a new name
96
     *
97
     * @param string $name
98
     * @return self
99
     */
100
    public function setName($name)
101
    {
102
        $this->name = $name;
103
        return $this;
104
    }
105
106
    /**
107
     * Gets as type
108
     *
109
     * @return string
110
     */
111
    public function getType()
112
    {
113
        return $this->type;
114
    }
115
116
    /**
117
     * Sets a new type
118
     *
119
     * @param string $type
120
     * @return self
121
     */
122
    public function setType($type)
123
    {
124
        $this->type = $type;
125
        return $this;
126
    }
127
128
    /**
129
     * Gets as nullable
130
     *
131
     * @return boolean
132
     */
133
    public function getNullable()
134
    {
135
        return $this->nullable;
136
    }
137
138
    /**
139
     * Sets a new nullable
140
     *
141
     * @param boolean $nullable
142
     * @return self
143
     */
144
    public function setNullable($nullable)
145
    {
146
        $this->nullable = $nullable;
147
        return $this;
148
    }
149
150
    /**
151
     * Gets as defaultValue
152
     *
153
     * @return string
154
     */
155
    public function getDefaultValue()
156
    {
157
        return $this->defaultValue;
158
    }
159
160
    /**
161
     * Sets a new defaultValue
162
     *
163
     * @param string $defaultValue
164
     * @return self
165
     */
166
    public function setDefaultValue($defaultValue)
167
    {
168
        $this->defaultValue = $defaultValue;
169
        return $this;
170
    }
171
172
    /**
173
     * Gets as maxLength
174
     *
175
     * @return string
176
     */
177
    public function getMaxLength()
178
    {
179
        return $this->maxLength;
180
    }
181
182
    /**
183
     * Sets a new maxLength
184
     *
185
     * @param string $maxLength
186
     * @return self
187
     */
188
    public function setMaxLength($maxLength)
189
    {
190
        $this->maxLength = $maxLength;
191
        return $this;
192
    }
193
194
    /**
195
     * Gets as fixedLength
196
     *
197
     * @return boolean
198
     */
199
    public function getFixedLength()
200
    {
201
        return $this->fixedLength;
202
    }
203
204
    /**
205
     * Sets a new fixedLength
206
     *
207
     * @param boolean $fixedLength
208
     * @return self
209
     */
210
    public function setFixedLength($fixedLength)
211
    {
212
        $this->fixedLength = $fixedLength;
213
        return $this;
214
    }
215
216
    /**
217
     * Gets as precision
218
     *
219
     * @return integer
220
     */
221
    public function getPrecision()
222
    {
223
        return $this->precision;
224
    }
225
226
    /**
227
     * Sets a new precision
228
     *
229
     * @param integer $precision
230
     * @return self
231
     */
232
    public function setPrecision($precision)
233
    {
234
        $this->precision = $precision;
235
        return $this;
236
    }
237
238
    /**
239
     * Gets as scale
240
     *
241
     * @return integer
242
     */
243
    public function getScale()
244
    {
245
        return $this->scale;
246
    }
247
248
    /**
249
     * Sets a new scale
250
     *
251
     * @param integer $scale
252
     * @return self
253
     */
254
    public function setScale($scale)
255
    {
256
        $this->scale = $scale;
257
        return $this;
258
    }
259
260
    /**
261
     * Gets as unicode
262
     *
263
     * @return boolean
264
     */
265
    public function getUnicode()
266
    {
267
        return $this->unicode;
268
    }
269
270
    /**
271
     * Sets a new unicode
272
     *
273
     * @param boolean $unicode
274
     * @return self
275
     */
276
    public function setUnicode($unicode)
277
    {
278
        $this->unicode = $unicode;
279
        return $this;
280
    }
281
282
    /**
283
     * Gets as collation
284
     *
285
     * @return string
286
     */
287
    public function getCollation()
288
    {
289
        return $this->collation;
290
    }
291
292
    /**
293
     * Sets a new collation
294
     *
295
     * @param string $collation
296
     * @return self
297
     */
298
    public function setCollation($collation)
299
    {
300
        $this->collation = $collation;
301
        return $this;
302
    }
303
304
    /**
305
     * Gets as sRID
306
     *
307
     * @return string
308
     */
309
    public function getSRID()
310
    {
311
        return $this->sRID;
312
    }
313
314
    /**
315
     * Sets a new sRID
316
     *
317
     * @param string $sRID
318
     * @return self
319
     */
320
    public function setSRID($sRID)
321
    {
322
        $this->sRID = $sRID;
323
        return $this;
324
    }
325
326
    /**
327
     * Gets as storeGeneratedPattern
328
     *
329
     * @return string
330
     */
331
    public function getStoreGeneratedPattern()
332
    {
333
        return $this->storeGeneratedPattern;
334
    }
335
336
    /**
337
     * Sets a new storeGeneratedPattern
338
     *
339
     * @param string $storeGeneratedPattern
340
     * @return self
341
     */
342
    public function setStoreGeneratedPattern($storeGeneratedPattern)
343
    {
344
        $this->storeGeneratedPattern = $storeGeneratedPattern;
345
        return $this;
346
    }
347
348
    /**
349
     * Gets as documentation
350
     *
351
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType
352
     */
353
    public function getDocumentation()
354
    {
355
        return $this->documentation;
356
    }
357
358
    /**
359
     * Sets a new documentation
360
     *
361
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
362
     * @return self
363
     */
364
    public function setDocumentation(TDocumentationType $documentation)
365
    {
366
        $this->documentation = $documentation;
367
        return $this;
368
    }
369
370
    public function isOK(&$msg = null)
371
    {
372
        if (!$this->isStringNotNullOrEmpty($this->name)) {
373
            $msg = "Name cannot be null or empty";
374
            return false;
375
        }
376
        if (!$this->isStringNotNullOrEmpty($this->type)) {
377
            $msg = "Type cannot be null or empty";
378
            return false;
379
        }
380 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...
381
            $msg = "Default value cannot be empty";
382
            return false;
383
        }
384 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...
385
            $msg = "Max length must be positive and numeric";
386
            return false;
387
        }
388 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...
389
            $msg = "Precision must be positive and numeric";
390
            return false;
391
        }
392 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...
393
            $msg = "Scale must be positive and numeric";
394
            return false;
395
        }
396 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...
397
            $msg = "Collation cannot be empty";
398
            return false;
399
        }
400 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...
401
            $msg = "SRID cannot be empty";
402
            return false;
403
        }
404
        if (null != $this->storeGeneratedPattern && !$this->isStringNotNullOrEmpty($this->storeGeneratedPattern)) {
405
            $msg = "Store generated pattern cannot be empty";
406
            return false;
407
        }
408
409
        if (!$this->isTSimpleIdentifierValid($this->name)) {
410
            $msg = "Name must be valid TSimpleIdentifier";
411
            return false;
412
        }
413
        if (!$this->isTPropertyTypeValid($this->type)) {
414
            $msg = "Type must be valid TPropertyType";
415
            return false;
416
        }
417
        if (null != $this->storeGeneratedPattern
418
            && !$this->isTStoreGeneratedPatternValid($this->storeGeneratedPattern)) {
419
            $msg = "Store generated pattern must be valid TStoreGeneratedPattern";
420
            return false;
421
        }
422
        if (!$this->isObjectNullOrOK($this->documentation, $msg)) {
423
            return false;
424
        }
425
426
        return true;
427
    }
428
}
429