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

TParameterType   A

Complexity

Total Complexity 27

Size/Duplication

Total Lines 249
Duplicated Lines 3.21 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 27
lcom 1
cbo 3
dl 8
loc 249
rs 10
c 0
b 0
f 0

17 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A setName() 0 5 1
A getType() 0 4 1
A setType() 0 5 1
A getMode() 0 4 1
A setMode() 0 5 1
A getMaxLength() 0 4 1
A setMaxLength() 0 5 1
A getPrecision() 0 4 1
A setPrecision() 0 5 1
A getScale() 0 4 1
A setScale() 0 5 1
A getSRID() 0 4 1
A setSRID() 0 5 1
A getDocumentation() 0 4 1
A setDocumentation() 0 5 1
C isOK() 8 29 11

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\ssdl;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TParameterModeTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TFunctionTypeTrait;
8
9
/**
10
 * Class representing TParameterType
11
 *
12
 *
13
 * XSD Type: TParameter
14
 */
15
class TParameterType extends IsOK
16
{
17
    use TParameterModeTrait, TFunctionTypeTrait;
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
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
55
     */
56
    private $documentation = null;
57
58
    /**
59
     * Gets as name
60
     *
61
     * @return string
62
     */
63
    public function getName()
64
    {
65
        return $this->name;
66
    }
67
68
    /**
69
     * Sets a new name
70
     *
71
     * @param string $name
72
     * @return self
73
     */
74
    public function setName($name)
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
        $this->type = $type;
99
        return $this;
100
    }
101
102
    /**
103
     * Gets as mode
104
     *
105
     * @return string
106
     */
107
    public function getMode()
108
    {
109
        return $this->mode;
110
    }
111
112
    /**
113
     * Sets a new mode
114
     *
115
     * @param string $mode
116
     * @return self
117
     */
118
    public function setMode($mode)
119
    {
120
        $this->mode = $mode;
121
        return $this;
122
    }
123
124
    /**
125
     * Gets as maxLength
126
     *
127
     * @return string
128
     */
129
    public function getMaxLength()
130
    {
131
        return $this->maxLength;
132
    }
133
134
    /**
135
     * Sets a new maxLength
136
     *
137
     * @param string $maxLength
138
     * @return self
139
     */
140
    public function setMaxLength($maxLength)
141
    {
142
        $this->maxLength = $maxLength;
143
        return $this;
144
    }
145
146
    /**
147
     * Gets as precision
148
     *
149
     * @return integer
150
     */
151
    public function getPrecision()
152
    {
153
        return $this->precision;
154
    }
155
156
    /**
157
     * Sets a new precision
158
     *
159
     * @param integer $precision
160
     * @return self
161
     */
162
    public function setPrecision($precision)
163
    {
164
        $this->precision = $precision;
165
        return $this;
166
    }
167
168
    /**
169
     * Gets as scale
170
     *
171
     * @return integer
172
     */
173
    public function getScale()
174
    {
175
        return $this->scale;
176
    }
177
178
    /**
179
     * Sets a new scale
180
     *
181
     * @param integer $scale
182
     * @return self
183
     */
184
    public function setScale($scale)
185
    {
186
        $this->scale = $scale;
187
        return $this;
188
    }
189
190
    /**
191
     * Gets as sRID
192
     *
193
     * @return string
194
     */
195
    public function getSRID()
196
    {
197
        return $this->sRID;
198
    }
199
200
    /**
201
     * Sets a new sRID
202
     *
203
     * @param string $sRID
204
     * @return self
205
     */
206
    public function setSRID($sRID)
207
    {
208
        $this->sRID = $sRID;
209
        return $this;
210
    }
211
212
    /**
213
     * Gets as documentation
214
     *
215
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType
216
     */
217
    public function getDocumentation()
218
    {
219
        return $this->documentation;
220
    }
221
222
    /**
223
     * Sets a new documentation
224
     *
225
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
226
     * @return self
227
     */
228
    public function setDocumentation(TDocumentationType $documentation)
229
    {
230
        $this->documentation = $documentation;
231
        return $this;
232
    }
233
234
    public function isOK(&$msg = null)
235
    {
236
        if (!$this->isStringNotNullOrEmpty($this->name)) {
237
            $msg = "Name cannot be null or empty";
238
            return false;
239
        }
240
        if (!$this->isStringNotNullOrEmpty($this->type)) {
241
            $msg = "Type cannot be null or empty";
242
            return false;
243
        }
244 View Code Duplication
        if (null != $this->mode && !$this->isStringNotNullOrEmpty($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...
245
            $msg = "Mode cannot be empty";
246
            return false;
247
        }
248 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...
249
            $msg = "SRID cannot be empty";
250
            return false;
251
        }
252
        if (null != $this->type && !$this->isTFunctionTypeValid($this->type)) {
253
            $msg = "Type must be a valid TFunctionType";
254
            return false;
255
        }
256
        if (null != $this->mode && !$this->isTParameterModeValid($this->mode)) {
257
            $msg = "Mode must be a valid TParameterMode";
258
            return false;
259
        }
260
261
        return true;
262
    }
263
}
264