Test Failed
Push — master ( c0ccaa...9d6468 )
by Alex
07:04
created

TFunctionImportParameterAttributesTrait   B

Complexity

Total Complexity 39

Size/Duplication

Total Lines 263
Duplicated Lines 28.14 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 39
lcom 1
cbo 7
dl 74
loc 263
rs 8.2857
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A setName() 10 10 2
A getType() 0 4 1
A setType() 0 10 2
A getMode() 0 4 1
A setMode() 4 10 3
A getMaxLength() 0 4 1
A setMaxLength() 10 10 3
A getPrecision() 0 4 1
A setPrecision() 10 10 3
A getScale() 0 4 1
A setScale() 10 10 3
A getSRID() 0 4 1
A setSRID() 10 10 3
C isTFunctionImportParameterAttributesValid() 20 33 13

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\MetadataV3\edm\IsOKTraits\TFunctionImportParameterAndReturnTypeTrait;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TMaxLengthFacetTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TParameterModeTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TPrecisionFacetTrait;
9
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TScaleFacetTrait;
10
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSimpleIdentifierTrait;
11
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TSridFacetTrait;
12
13
trait TFunctionImportParameterAttributesTrait
14
{
15
    use TSimpleIdentifierTrait, TParameterModeTrait, TFunctionImportParameterAndReturnTypeTrait, TMaxLengthFacetTrait,
16
        TPrecisionFacetTrait, TScaleFacetTrait, TSridFacetTrait;
17
18
    /*
19
     * @property string $name
20
     */
21
    private $name = null;
22
23
    /**
24
     * @property string $type
25
     */
26
    private $type = null;
27
28
    /**
29
     * @property string $mode
30
     */
31
    private $mode = null;
32
33
    /**
34
     * @property string $maxLength
35
     */
36
    private $maxLength = 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 string $sRID
50
     */
51
    private $sRID = null;
52
53
    /**
54
     * Gets as name
55
     *
56
     * @return string
57
     */
58
    public function getName()
59
    {
60
        return $this->name;
61
    }
62
63
    /**
64
     * Sets a new name
65
     *
66
     * @param string $name
67
     * @return self
68
     */
69 View Code Duplication
    public function setName($name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
70
    {
71
        $msg = null;
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
72
        if (!$this->isTSimpleIdentifierValid($name)) {
73
            $msg = "Name must be a valid TSimpleIdentifier";
74
            throw new \InvalidArgumentException($msg);
75
        }
76
        $this->name = $name;
77
        return $this;
78
    }
79
80
    /**
81
     * Gets as type
82
     *
83
     * @return string
84
     */
85
    public function getType()
86
    {
87
        return $this->type;
88
    }
89
90
    /**
91
     * Sets a new type
92
     *
93
     * @param string $type
94
     * @return self
95
     */
96
    public function setType($type)
97
    {
98
        $msg = null;
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
99
        if (!$this->isTFunctionImportParameterAndReturnTypeValid($type)) {
100
            $msg = "Type must be a valid TFunctionImportParameterAndReturnType";
101
            throw new \InvalidArgumentException($msg);
102
        }
103
        $this->type = $type;
104
        return $this;
105
    }
106
107
    /**
108
     * Gets as mode
109
     *
110
     * @return string
111
     */
112
    public function getMode()
113
    {
114
        return $this->mode;
115
    }
116
117
    /**
118
     * Sets a new mode
119
     *
120
     * @param string $mode
121
     * @return self
122
     */
123
    public function setMode($mode)
124
    {
125
        $msg = null;
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
126 View Code Duplication
        if (null != $mode && !$this->isTParameterModeValid($mode)) {
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...
127
            $msg = "Mode must be a valid TParameterMode";
128
            throw new \InvalidArgumentException($msg);
129
        }
130
        $this->mode = $mode;
131
        return $this;
132
    }
133
134
    /**
135
     * Gets as maxLength
136
     *
137
     * @return string
138
     */
139
    public function getMaxLength()
140
    {
141
        return $this->maxLength;
142
    }
143
144
    /**
145
     * Sets a new maxLength
146
     *
147
     * @param string $maxLength
148
     * @return self
149
     */
150 View Code Duplication
    public function setMaxLength($maxLength)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
151
    {
152
        $msg = null;
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
153
        if (null != $maxLength && !$this->isTMaxLengthFacetValid($maxLength)) {
154
            $msg = "Max length must be a valid TMaxLengthFacet";
155
            throw new \InvalidArgumentException($msg);
156
        }
157
        $this->maxLength = $maxLength;
158
        return $this;
159
    }
160
161
    /**
162
     * Gets as precision
163
     *
164
     * @return integer
165
     */
166
    public function getPrecision()
167
    {
168
        return $this->precision;
169
    }
170
171
    /**
172
     * Sets a new precision
173
     *
174
     * @param integer $precision
175
     * @return self
176
     */
177 View Code Duplication
    public function setPrecision($precision)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
178
    {
179
        $msg = null;
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
180
        if (null != $precision && !$this->isTPrecisionFacetValid($precision)) {
181
            $msg = "Precision must be a valid TPrecisionFacet";
182
            throw new \InvalidArgumentException($msg);
183
        }
184
        $this->precision = $precision;
185
        return $this;
186
    }
187
188
    /**
189
     * Gets as scale
190
     *
191
     * @return integer
192
     */
193
    public function getScale()
194
    {
195
        return $this->scale;
196
    }
197
198
    /**
199
     * Sets a new scale
200
     *
201
     * @param integer $scale
202
     * @return self
203
     */
204 View Code Duplication
    public function setScale($scale)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
205
    {
206
        $msg = null;
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
207
        if (null != $scale && !$this->isTScaleFacetValid($scale)) {
208
            $msg = "Scale must be a valid TScaleFacet";
209
            throw new \InvalidArgumentException($msg);
210
        }
211
        $this->scale = $scale;
212
        return $this;
213
    }
214
215
    /**
216
     * Gets as sRID
217
     *
218
     * @return string
219
     */
220
    public function getSRID()
221
    {
222
        return $this->sRID;
223
    }
224
225
    /**
226
     * Sets a new sRID
227
     *
228
     * @param string $sRID
229
     * @return self
230
     */
231 View Code Duplication
    public function setSRID($sRID)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
232
    {
233
        $msg = null;
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
234
        if (null != $sRID && !$this->isTSridFacetValid($sRID)) {
235
            $msg = "SRID must be a valid TSRIDFacet";
236
            throw new \InvalidArgumentException($msg);
237
        }
238
        $this->sRID = $sRID;
239
        return $this;
240
    }
241
242
    public function isTFunctionImportParameterAttributesValid(&$msg = null)
243
    {
244
        if (!$this->isTSimpleIdentifierValid($this->name)) {
245
            $msg = "Name must be a valid TSimpleIdentifier";
246
            return false;
247
        }
248
        if (!$this->isTFunctionImportParameterAndReturnTypeValid($this->type)) {
249
            $msg = "Type must be a valid TFunctionImportParameterAndReturnType";
250
            return false;
251
        }
252 View Code Duplication
        if (null != $this->mode && !$this->isTParameterModeValid($this->mode)) {
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...
253
            $msg = "Mode must be a valid TParameterMode";
254
            return false;
255
        }
256 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...
257
            $msg = "Max length must be a valid TMaxLengthFacet";
258
            return false;
259
        }
260 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...
261
            $msg = "Precision must be a valid TPrecisionFacet";
262
            return false;
263
        }
264 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...
265
            $msg = "Scale must be a valid TScaleFacet";
266
            return false;
267
        }
268 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...
269
            $msg = "SRID must be a valid TSRIDFacet";
270
            return false;
271
        }
272
273
        return true;
274
    }
275
}
276