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

TFacetAttributesTrait::getScale()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\Groups;
4
5
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TIsFixedLengthFacetTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TIsUnicodeFacetTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TMaxLengthFacetTrait;
9
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TPrecisionFacetTrait;
10
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TScaleFacetTrait;
11
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSridFacetTrait;
12
13
trait TFacetAttributesTrait
14
{
15
    use IsOKToolboxTrait, TMaxLengthFacetTrait, TIsFixedLengthFacetTrait, TPrecisionFacetTrait, TScaleFacetTrait,
16
        TIsUnicodeFacetTrait, TSridFacetTrait;
17
    /**
18
     * @property boolean $nullable
19
     */
20
    private $nullable = null;
21
22
    /**
23
     * @property string $defaultValue
24
     */
25
    private $defaultValue = null;
26
27
    /**
28
     * @property string $maxLength
29
     */
30
    private $maxLength = null;
31
32
    /**
33
     * @property boolean $fixedLength
34
     */
35
    private $fixedLength = null;
36
37
    /**
38
     * @property integer $precision
39
     */
40
    private $precision = null;
41
42
    /**
43
     * @property integer $scale
44
     */
45
    private $scale = null;
46
47
    /**
48
     * @property boolean $unicode
49
     */
50
    private $unicode = null;
51
52
    /**
53
     * @property string $collation
54
     */
55
    private $collation = null;
56
57
    /**
58
     * @property string $sRID
59
     */
60
    private $sRID = null;
61
62
    /**
63
     * Gets as nullable
64
     *
65
     * @return boolean
66
     */
67
    public function getNullable()
68
    {
69
        return $this->nullable;
70
    }
71
72
    /**
73
     * Sets a new nullable
74
     *
75
     * @param boolean $nullable
76
     * @return self
77
     */
78
    public function setNullable($nullable)
79
    {
80
        $this->nullable = $nullable;
81
        return $this;
82
    }
83
84
    /**
85
     * Gets as defaultValue
86
     *
87
     * @return string
88
     */
89
    public function getDefaultValue()
90
    {
91
        return $this->defaultValue;
92
    }
93
94
    /**
95
     * Sets a new defaultValue
96
     *
97
     * @param string $defaultValue
98
     * @return self
99
     */
100
    public function setDefaultValue($defaultValue)
101
    {
102
        $this->defaultValue = $defaultValue;
103
        return $this;
104
    }
105
106
    /**
107
     * Gets as maxLength
108
     *
109
     * @return string
110
     */
111
    public function getMaxLength()
112
    {
113
        return $this->maxLength;
114
    }
115
116
    /**
117
     * Sets a new maxLength
118
     *
119
     * @param string $maxLength
120
     * @return self
121
     */
122
    public function setMaxLength($maxLength)
123
    {
124
        $this->maxLength = $maxLength;
125
        return $this;
126
    }
127
128
    /**
129
     * Gets as fixedLength
130
     *
131
     * @return boolean
132
     */
133
    public function getFixedLength()
134
    {
135
        return $this->fixedLength;
136
    }
137
138
    /**
139
     * Sets a new fixedLength
140
     *
141
     * @param boolean $fixedLength
142
     * @return self
143
     */
144
    public function setFixedLength($fixedLength)
145
    {
146
        $this->fixedLength = $fixedLength;
147
        return $this;
148
    }
149
150
    /**
151
     * Gets as precision
152
     *
153
     * @return integer
154
     */
155
    public function getPrecision()
156
    {
157
        return $this->precision;
158
    }
159
160
    /**
161
     * Sets a new precision
162
     *
163
     * @param integer $precision
164
     * @return self
165
     */
166
    public function setPrecision($precision)
167
    {
168
        $this->precision = $precision;
169
        return $this;
170
    }
171
172
    /**
173
     * Gets as scale
174
     *
175
     * @return integer
176
     */
177
    public function getScale()
178
    {
179
        return $this->scale;
180
    }
181
182
    /**
183
     * Sets a new scale
184
     *
185
     * @param integer $scale
186
     * @return self
187
     */
188
    public function setScale($scale)
189
    {
190
        $this->scale = $scale;
191
        return $this;
192
    }
193
194
    /**
195
     * Gets as unicode
196
     *
197
     * @return boolean
198
     */
199
    public function getUnicode()
200
    {
201
        return $this->unicode;
202
    }
203
204
    /**
205
     * Sets a new unicode
206
     *
207
     * @param boolean $unicode
208
     * @return self
209
     */
210
    public function setUnicode($unicode)
211
    {
212
        $this->unicode = $unicode;
213
        return $this;
214
    }
215
216
    /**
217
     * Gets as collation
218
     *
219
     * @return string
220
     */
221
    public function getCollation()
222
    {
223
        return $this->collation;
224
    }
225
226
    /**
227
     * Sets a new collation
228
     *
229
     * @param string $collation
230
     * @return self
231
     */
232
    public function setCollation($collation)
233
    {
234
        $this->collation = $collation;
235
        return $this;
236
    }
237
238
    /**
239
     * Gets as sRID
240
     *
241
     * @return string
242
     */
243
    public function getSRID()
244
    {
245
        return $this->sRID;
246
    }
247
248
    /**
249
     * Sets a new sRID
250
     *
251
     * @param string $sRID
252
     * @return self
253
     */
254
    public function setSRID($sRID)
255
    {
256
        $this->sRID = $sRID;
257
        return $this;
258
    }
259
260
    public function isTFacetAttributesTraitValid(&$msg = null)
261
    {
262
        if ($this->nullable !== boolval($this->nullable)) {
263
            $msg = "Nullable must be boolean";
264
            return false;
265
        }
266 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...
267
            $msg = "Default value must be a string";
268
            return false;
269
        }
270 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...
271
            $msg = "Max length must be a valid TMaxLengthFacet";
272
            return false;
273
        }
274 View Code Duplication
        if (null != $this->fixedLength && !$this->isTIsFixedLengthFacetTraitValid($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...
275
            $msg = "Fixed length must be a valid TFixedLengthFacet";
276
            return false;
277
        }
278 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...
279
            $msg = "Precision must be a valid TPrecisionFacet";
280
            return false;
281
        }
282 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...
283
            $msg = "Scale must be a valid TScaleFacet";
284
            return false;
285
        }
286 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...
287
            $msg = "SRID must be a valid TSridFacet";
288
            return false;
289
        }
290 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...
291
            $msg = "Unicode must be a valid TUnicodeFacet";
292
            return false;
293
        }
294
295
        return true;
296
    }
297
}
298