Passed
Push — master ( 497f66...189420 )
by Alex
04:13
created

TFacetAttributesTrait   B

Complexity

Total Complexity 36

Size/Duplication

Total Lines 289
Duplicated Lines 11.07 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
wmc 36
lcom 1
cbo 8
dl 32
loc 289
rs 8.8
c 0
b 0
f 0

19 Methods

Rating   Name   Duplication   Size   Complexity  
A getNullable() 0 4 1
A setNullable() 0 5 1
A getDefaultValue() 0 4 1
A setDefaultValue() 0 5 1
A getMaxLength() 0 4 1
A setMaxLength() 0 5 1
A getFixedLength() 0 4 1
A setFixedLength() 0 5 1
A getPrecision() 0 4 1
A setPrecision() 0 5 1
A getScale() 0 4 1
A setScale() 0 5 1
A getUnicode() 0 4 1
A setUnicode() 0 5 1
A getCollation() 0 4 1
A setCollation() 0 5 1
A getSRID() 0 4 1
A setSRID() 0 5 1
D isTFacetAttributesTraitValid() 32 41 18

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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