Passed
Push — master ( feaee9...2b3e4e )
by Alex
04:28
created

TCommonPropertyAttributesTrait::setSetterAccess()   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\Groups;
4
5
use AlgoWeb\ODataMetadata\CodeGeneration\AccessTypeTraits;
6
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TCollationFacetTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TConcurrencyModeTrait;
9
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TIsFixedLengthFacetTrait;
10
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TIsUnicodeFacetTrait;
11
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TMaxLengthFacetTrait;
12
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TPrecisionFacetTrait;
13
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TScaleFacetTrait;
14
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait;
15
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSridFacetTrait;
16
17
trait TCommonPropertyAttributesTrait
18
{
19
    use TSimpleIdentifierTrait, TMaxLengthFacetTrait, TIsFixedLengthFacetTrait, TPrecisionFacetTrait, TScaleFacetTrait,
20
        TIsUnicodeFacetTrait, TCollationFacetTrait, TSridFacetTrait, TConcurrencyModeTrait, AccessTypeTraits,
21
        IsOKToolboxTrait;
22
23
    /**
24
     * @property string $name
25
     */
26
    private $name = null;
27
28
    /**
29
     * @property string $type
30
     */
31
    private $type = null;
32
33
    /**
34
     * @property boolean $nullable
35
     */
36
    private $nullable = true;
37
38
    /**
39
     * @property string $defaultValue
40
     */
41
    private $defaultValue = null;
42
43
    /**
44
     * @property string $maxLength
45
     */
46
    private $maxLength = null;
47
48
    /**
49
     * @property boolean $fixedLength
50
     */
51
    private $fixedLength = null;
52
53
    /**
54
     * @property integer $precision
55
     */
56
    private $precision = null;
57
58
    /**
59
     * @property integer $scale
60
     */
61
    private $scale = null;
62
63
    /**
64
     * @property boolean $unicode
65
     */
66
    private $unicode = null;
67
68
    /**
69
     * @property string $collation
70
     */
71
    private $collation = null;
72
73
    /**
74
     * @property string $sRID
75
     */
76
    private $sRID = null;
77
78
    /**
79
     * @property string $concurrencyMode
80
     */
81
    private $concurrencyMode = null;
82
83
    /**
84
     * @property string $setterAccess
85
     */
86
    private $setterAccess = null;
87
88
    /**
89
     * @property string $getterAccess
90
     */
91
    private $getterAccess = null;
92
93
    /**
94
     * Gets as name
95
     *
96
     * @return string
97
     */
98
    public function getName()
99
    {
100
        return $this->name;
101
    }
102
103
    /**
104
     * Sets a new name
105
     *
106
     * @param string $name
107
     * @return self
108
     */
109
    public function setName($name)
110
    {
111
        $this->name = $name;
112
        return $this;
113
    }
114
115
    /**
116
     * Gets as type
117
     *
118
     * @return string
119
     */
120
    public function getType()
121
    {
122
        return $this->type;
123
    }
124
125
    /**
126
     * Sets a new type
127
     *
128
     * @param string $type
129
     * @return self
130
     */
131
    public function setType($type)
132
    {
133
        $this->type = $type;
134
        return $this;
135
    }
136
137
    /**
138
     * Gets as nullable
139
     *
140
     * @return boolean
141
     */
142
    public function getNullable()
143
    {
144
        return $this->nullable;
145
    }
146
147
    /**
148
     * Sets a new nullable
149
     *
150
     * @param boolean $nullable
151
     * @return self
152
     */
153
    public function setNullable($nullable)
154
    {
155
        $this->nullable = $nullable;
156
        return $this;
157
    }
158
159
    /**
160
     * Gets as defaultValue
161
     *
162
     * @return string
163
     */
164
    public function getDefaultValue()
165
    {
166
        return $this->defaultValue;
167
    }
168
169
    /**
170
     * Sets a new defaultValue
171
     *
172
     * @param string $defaultValue
173
     * @return self
174
     */
175
    public function setDefaultValue($defaultValue)
176
    {
177
        $this->defaultValue = $defaultValue;
178
        return $this;
179
    }
180
181
    /**
182
     * Gets as maxLength
183
     *
184
     * @return string
185
     */
186
    public function getMaxLength()
187
    {
188
        return $this->maxLength;
189
    }
190
191
    /**
192
     * Sets a new maxLength
193
     *
194
     * @param string $maxLength
195
     * @return self
196
     */
197
    public function setMaxLength($maxLength)
198
    {
199
        $this->maxLength = $maxLength;
200
        return $this;
201
    }
202
203
    /**
204
     * Gets as fixedLength
205
     *
206
     * @return boolean
207
     */
208
    public function getFixedLength()
209
    {
210
        return $this->fixedLength;
211
    }
212
213
    /**
214
     * Sets a new fixedLength
215
     *
216
     * @param boolean $fixedLength
217
     * @return self
218
     */
219
    public function setFixedLength($fixedLength)
220
    {
221
        $this->fixedLength = $fixedLength;
222
        return $this;
223
    }
224
225
    /**
226
     * Gets as precision
227
     *
228
     * @return integer
229
     */
230
    public function getPrecision()
231
    {
232
        return $this->precision;
233
    }
234
235
    /**
236
     * Sets a new precision
237
     *
238
     * @param integer $precision
239
     * @return self
240
     */
241
    public function setPrecision($precision)
242
    {
243
        $this->precision = $precision;
244
        return $this;
245
    }
246
247
    /**
248
     * Gets as scale
249
     *
250
     * @return integer
251
     */
252
    public function getScale()
253
    {
254
        return $this->scale;
255
    }
256
257
    /**
258
     * Sets a new scale
259
     *
260
     * @param integer $scale
261
     * @return self
262
     */
263
    public function setScale($scale)
264
    {
265
        $this->scale = $scale;
266
        return $this;
267
    }
268
269
    /**
270
     * Gets as unicode
271
     *
272
     * @return boolean
273
     */
274
    public function getUnicode()
275
    {
276
        return $this->unicode;
277
    }
278
279
    /**
280
     * Sets a new unicode
281
     *
282
     * @param boolean $unicode
283
     * @return self
284
     */
285
    public function setUnicode($unicode)
286
    {
287
        $this->unicode = $unicode;
288
        return $this;
289
    }
290
291
    /**
292
     * Gets as collation
293
     *
294
     * @return string
295
     */
296
    public function getCollation()
297
    {
298
        return $this->collation;
299
    }
300
301
    /**
302
     * Sets a new collation
303
     *
304
     * @param string $collation
305
     * @return self
306
     */
307
    public function setCollation($collation)
308
    {
309
        $this->collation = $collation;
310
        return $this;
311
    }
312
313
    /**
314
     * Gets as sRID
315
     *
316
     * @return string
317
     */
318
    public function getSRID()
319
    {
320
        return $this->sRID;
321
    }
322
323
    /**
324
     * Sets a new sRID
325
     *
326
     * @param string $sRID
327
     * @return self
328
     */
329
    public function setSRID($sRID)
330
    {
331
        $this->sRID = $sRID;
332
        return $this;
333
    }
334
335
    /**
336
     * Gets as concurrencyMode
337
     *
338
     * @return string
339
     */
340
    public function getConcurrencyMode()
341
    {
342
        return $this->concurrencyMode;
343
    }
344
345
    /**
346
     * Sets a new concurrencyMode
347
     *
348
     * @param string $concurrencyMode
349
     * @return self
350
     */
351
    public function setConcurrencyMode($concurrencyMode)
352
    {
353
        $this->concurrencyMode = $concurrencyMode;
354
        return $this;
355
    }
356
357
    /**
358
     * Gets as setterAccess
359
     *
360
     * @return string
361
     */
362
    public function getSetterAccess()
363
    {
364
        return $this->setterAccess;
365
    }
366
367
    /**
368
     * Sets a new setterAccess
369
     *
370
     * @param string $setterAccess
371
     * @return self
372
     */
373
    public function setSetterAccess($setterAccess)
374
    {
375
        $this->setterAccess = $setterAccess;
376
        return $this;
377
    }
378
379
    /**
380
     * Gets as getterAccess
381
     *
382
     * @return string
383
     */
384
    public function getGetterAccess()
385
    {
386
        return $this->getterAccess;
387
    }
388
389
    /**
390
     * Sets a new getterAccess
391
     *
392
     * @param string $getterAccess
393
     * @return self
394
     */
395
    public function setGetterAccess($getterAccess)
396
    {
397
        $this->getterAccess = $getterAccess;
398
        return $this;
399
    }
400
401
    public function isTCommonPropertyAttributesValid(&$msg = null)
402
    {
403
        if (!$this->isTSimpleIdentifierValid($this->name)) {
404
            $msg = "Name must be a valid TSimpleIdentifier";
405
            return false;
406
        }
407
        if (null != $this->nullable && $this->nullable !== boolval($this->nullable)) {
408
            $msg = "Nullable must be boolean";
409
            return false;
410
        }
411 View Code Duplication
        if (null != $this->defaultValue && !is_string($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...
412
            $msg = "Default value must be a string";
413
            return false;
414
        }
415 View Code Duplication
        if (null != $this->maxLength && !$this->isTMaxLengthFacetValid($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...
416
            $msg = "Max length must be a valid TMaxLengthFacet";
417
            return false;
418
        }
419 View Code Duplication
        if (null != $this->fixedLength && !$this->isTIsFixedLengthFacetTraitValid($this->fixedLength)) {
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...
420
            $msg = "Max length must be a valid TFixedLengthFacet";
421
            return false;
422
        }
423 View Code Duplication
        if (null != $this->precision && !$this->isTPrecisionFacetValid($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...
424
            $msg = "Precision must be a valid TPrecisionFacet";
425
            return false;
426
        }
427 View Code Duplication
        if (null != $this->scale && !$this->isTScaleFacetValid($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...
428
            $msg = "Scale must be a valid TScaleFacet";
429
            return false;
430
        }
431 View Code Duplication
        if (null != $this->unicode && !$this->isTIsUnicodeFacetTraitValid($this->unicode)) {
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...
432
            $msg = "Unicode must be a valid TUnicodeFacet";
433
            return false;
434
        }
435
        if (null != $this->collation && !$this->isTCollationFacetValid($this->collation)) {
436
            $msg = "Collation must be a valid TCollationFacet";
437
            return false;
438
        }
439 View Code Duplication
        if (null != $this->sRID && !$this->isTSridFacetValid($this->sRID)) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->isTSridFacetValid($this->sRID) of type false|integer is loosely compared to false; this is ambiguous if the integer can be zero. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
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...
440
            $msg = "SRID must be a valid TSridFacet";
441
            return false;
442
        }
443
        if (null != $this->concurrencyMode && !$this->isTConcurrencyModeValid($this->concurrencyMode)) {
444
            $msg = "ConcurrencyMode must be a valid TConcurrencyMode";
445
            return false;
446
        }
447
        if (null != $this->setterAccess && !$this->isTAccessOk($this->setterAccess)) {
448
            $msg = "Setter access must be a valid TAccess";
449
            return false;
450
        }
451 View Code Duplication
        if (null != $this->getterAccess && !$this->isTAccessOk($this->getterAccess)) {
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...
452
            $msg = "Getter access must be a valid TAccess";
453
            return false;
454
        }
455
456
        return true;
457
    }
458
}
459