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

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\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
    public function setName($name)
70
    {
71
        $this->name = $name;
72
        return $this;
73
    }
74
75
    /**
76
     * Gets as type
77
     *
78
     * @return string
79
     */
80
    public function getType()
81
    {
82
        return $this->type;
83
    }
84
85
    /**
86
     * Sets a new type
87
     *
88
     * @param string $type
89
     * @return self
90
     */
91
    public function setType($type)
92
    {
93
        $this->type = $type;
94
        return $this;
95
    }
96
97
    /**
98
     * Gets as mode
99
     *
100
     * @return string
101
     */
102
    public function getMode()
103
    {
104
        return $this->mode;
105
    }
106
107
    /**
108
     * Sets a new mode
109
     *
110
     * @param string $mode
111
     * @return self
112
     */
113
    public function setMode($mode)
114
    {
115
        $this->mode = $mode;
116
        return $this;
117
    }
118
119
    /**
120
     * Gets as maxLength
121
     *
122
     * @return string
123
     */
124
    public function getMaxLength()
125
    {
126
        return $this->maxLength;
127
    }
128
129
    /**
130
     * Sets a new maxLength
131
     *
132
     * @param string $maxLength
133
     * @return self
134
     */
135
    public function setMaxLength($maxLength)
136
    {
137
        $this->maxLength = $maxLength;
138
        return $this;
139
    }
140
141
    /**
142
     * Gets as precision
143
     *
144
     * @return integer
145
     */
146
    public function getPrecision()
147
    {
148
        return $this->precision;
149
    }
150
151
    /**
152
     * Sets a new precision
153
     *
154
     * @param integer $precision
155
     * @return self
156
     */
157
    public function setPrecision($precision)
158
    {
159
        $this->precision = $precision;
160
        return $this;
161
    }
162
163
    /**
164
     * Gets as scale
165
     *
166
     * @return integer
167
     */
168
    public function getScale()
169
    {
170
        return $this->scale;
171
    }
172
173
    /**
174
     * Sets a new scale
175
     *
176
     * @param integer $scale
177
     * @return self
178
     */
179
    public function setScale($scale)
180
    {
181
        $this->scale = $scale;
182
        return $this;
183
    }
184
185
    /**
186
     * Gets as sRID
187
     *
188
     * @return string
189
     */
190
    public function getSRID()
191
    {
192
        return $this->sRID;
193
    }
194
195
    /**
196
     * Sets a new sRID
197
     *
198
     * @param string $sRID
199
     * @return self
200
     */
201
    public function setSRID($sRID)
202
    {
203
        $this->sRID = $sRID;
204
        return $this;
205
    }
206
207
    public function isTFunctionImportParameterAttributesValid(&$msg = null)
208
    {
209
        if (!$this->isTSimpleIdentifierValid($this->name)) {
210
            $msg = "Name must be a valid TSimpleIdentifier";
211
            return false;
212
        }
213
        if (!$this->isTFunctionImportParameterAndReturnTypeValid($this->type)) {
214
            $msg = "Type must be a valid TFunctionImportParameterAndReturnType";
215
            return false;
216
        }
217 View Code Duplication
        if (null != $this->mode && !$this->isTParameterModeValid($this->mode)) {
0 ignored issues
show
Bug introduced by
It seems like isTParameterModeValid() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

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...
218
            $msg = "Mode must be a valid TParameterMode";
219
            return false;
220
        }
221 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...
222
            $msg = "Max length must be a valid TMaxLengthFacet";
223
            return false;
224
        }
225 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...
226
            $msg = "Precision must be a valid TPrecisionFacet";
227
            return false;
228
        }
229
        if (null != $this->scale && !$this->isTPrecisionFacetValid($this->scale)) {
230
            $msg = "Scale must be a valid TScaleFacet";
231
            return false;
232
        }
233
        if (null != $this->sRID && !$this->isTPrecisionFacetValid($this->sRID)) {
234
            $msg = "SRID must be a valid TSRIDFacet";
235
            return false;
236
        }
237
238
        return true;
239
    }
240
}
241