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

GInlineExpressionsTrait::setDecimal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\Groups;
4
5
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TGuidLiteralTrait;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TQualifiedNameTrait;
7
use AlgoWeb\ODataMetadata\StringTraits\XSDTopLevelTrait;
8
9
trait GInlineExpressionsTrait
10
{
11
    use TQualifiedNameTrait, XSDTopLevelTrait, TGuidLiteralTrait;
12
13
    /**
14
     * @property string $string
15
     */
16
    private $string = null;
17
18
    /**
19
     * @property mixed $binary
20
     */
21
    private $binary = null;
22
23
    /**
24
     * @property integer $int
25
     */
26
    private $int = null;
27
28
    /**
29
     * @property float $float
30
     */
31
    private $float = null;
32
33
    /**
34
     * @property string $guid
35
     */
36
    private $guid = null;
37
38
    /**
39
     * @property float $decimal
40
     */
41
    private $decimal = null;
42
43
    /**
44
     * @property boolean $bool
45
     */
46
    private $bool = null;
47
48
    /**
49
     * @property \DateTime $dateTime
50
     */
51
    private $dateTime = null;
52
53
    /**
54
     * @property \DateTime $dateTimeOffset
55
     */
56
    private $dateTimeOffset = null;
57
58
    /**
59
     * @property string $enum
60
     */
61
    private $enum = null;
62
63
    /**
64
     * @property string $path
65
     */
66
    private $path = null;
67
68
    /**
69
     * Gets as string
70
     *
71
     * @return string
72
     */
73
    public function getString()
74
    {
75
        return $this->string;
76
    }
77
78
    /**
79
     * Sets a new string
80
     *
81
     * @param string $string
82
     * @return self
83
     */
84
    public function setString($string)
85
    {
86
        $this->string = $string;
87
        return $this;
88
    }
89
90
    /**
91
     * Gets as binary
92
     *
93
     * @return mixed
94
     */
95
    public function getBinary()
96
    {
97
        return $this->binary;
98
    }
99
100
    /**
101
     * Sets a new binary
102
     *
103
     * @param mixed $binary
104
     * @return self
105
     */
106
    public function setBinary($binary)
107
    {
108
        $this->binary = $binary;
109
        return $this;
110
    }
111
112
    /**
113
     * Gets as int
114
     *
115
     * @return integer
116
     */
117
    public function getInt()
118
    {
119
        return $this->int;
120
    }
121
122
    /**
123
     * Sets a new int
124
     *
125
     * @param integer $int
126
     * @return self
127
     */
128
    public function setInt($int)
129
    {
130
        $this->int = $int;
131
        return $this;
132
    }
133
134
    /**
135
     * Gets as float
136
     *
137
     * @return float
138
     */
139
    public function getFloat()
140
    {
141
        return $this->float;
142
    }
143
144
    /**
145
     * Sets a new float
146
     *
147
     * @param float $float
148
     * @return self
149
     */
150
    public function setFloat($float)
151
    {
152
        $this->float = $float;
153
        return $this;
154
    }
155
156
    /**
157
     * Gets as guid
158
     *
159
     * @return string
160
     */
161
    public function getGuid()
162
    {
163
        return $this->guid;
164
    }
165
166
    /**
167
     * Sets a new guid
168
     *
169
     * @param string $guid
170
     * @return self
171
     */
172
    public function setGuid($guid)
173
    {
174
        $this->guid = $guid;
175
        return $this;
176
    }
177
178
    /**
179
     * Gets as decimal
180
     *
181
     * @return float
182
     */
183
    public function getDecimal()
184
    {
185
        return $this->decimal;
186
    }
187
188
    /**
189
     * Sets a new decimal
190
     *
191
     * @param float $decimal
192
     * @return self
193
     */
194
    public function setDecimal($decimal)
195
    {
196
        $this->decimal = $decimal;
197
        return $this;
198
    }
199
200
    /**
201
     * Gets as bool
202
     *
203
     * @return boolean
204
     */
205
    public function getBool()
206
    {
207
        return $this->bool;
208
    }
209
210
    /**
211
     * Sets a new bool
212
     *
213
     * @param boolean $bool
214
     * @return self
215
     */
216
    public function setBool($bool)
217
    {
218
        $this->bool = $bool;
219
        return $this;
220
    }
221
222
    /**
223
     * Gets as dateTime
224
     *
225
     * @return \DateTime
226
     */
227
    public function getDateTime()
228
    {
229
        return $this->dateTime;
230
    }
231
232
    /**
233
     * Sets a new dateTime
234
     *
235
     * @param \DateTime $dateTime
236
     * @return self
237
     */
238
    public function setDateTime(\DateTime $dateTime)
239
    {
240
        $this->dateTime = $dateTime;
241
        return $this;
242
    }
243
244
    /**
245
     * Gets as dateTimeOffset
246
     *
247
     * @return \DateTime
248
     */
249
    public function getDateTimeOffset()
250
    {
251
        return $this->dateTimeOffset;
252
    }
253
254
    /**
255
     * Sets a new dateTimeOffset
256
     *
257
     * @param \DateTime $dateTimeOffset
258
     * @return self
259
     */
260
    public function setDateTimeOffset(\DateTime $dateTimeOffset)
261
    {
262
        $this->dateTimeOffset = $dateTimeOffset;
263
        return $this;
264
    }
265
266
    /**
267
     * Gets as enum
268
     *
269
     * @return string
270
     */
271
    public function getEnum()
272
    {
273
        return $this->enum;
274
    }
275
276
    /**
277
     * Sets a new enum
278
     *
279
     * @param string $enum
280
     * @return self
281
     */
282
    public function setEnum($enum)
283
    {
284
        $this->enum = $enum;
285
        return $this;
286
    }
287
288
    /**
289
     * Gets as path
290
     *
291
     * @return string
292
     */
293
    public function getPath()
294
    {
295
        return $this->path;
296
    }
297
298
    /**
299
     * Sets a new path
300
     *
301
     * @param string $path
302
     * @return self
303
     */
304
    public function setPath($path)
305
    {
306
        $this->path = $path;
307
        return $this;
308
    }
309
310
    public function isGInlineExpressionsValid(&$msg = null)
311
    {
312
        if (null != $this->string && !is_string($this->string)) {
313
            $msg = "String must be a string";
314
            return false;
315
        }
316
        if (null != $this->binary && !$this->hexBinary($this->binary)) {
317
            $msg = "Binary must be hexadecimal";
318
            return false;
319
        }
320
        if (null != $this->int && $this->int !== intval($this->int)) {
321
            $msg = "Integer must be integral";
322
            return false;
323
        }
324
        if (null != $this->float && $this->float !== floatval($this->float)) {
325
            $msg = "Float must be floating-point";
326
            return false;
327
        }
328
        if (null != $this->guid && !$this->isTGuidLiteralValid($this->guid)) {
329
            $msg = "Guid must be valid GUID";
330
            return false;
331
        }
332
        if (null != $this->bool && $this->bool !== boolval($this->bool)) {
333
            $msg = "Bool must be boolean";
334
            return false;
335
        }
336
        if (null != $this->decimal && $this->decimal !== floatval($this->decimal)) {
337
            $msg = "Decimal must be decimal";
338
            return false;
339
        }
340 View Code Duplication
        if (null != $this->enum && !$this->isTQualifiedNameValid($this->enum)) {
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...
341
            $msg = "Enum must be a valid TQualifiedName";
342
            return false;
343
        }
344 View Code Duplication
        if (null != $this->path && !$this->isTQualifiedNameValid($this->path)) {
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...
345
            $msg = "Path must be a valid TQualifiedName";
346
            return false;
347
        }
348
        if (null != $this->dateTime && $this->dateTime !== $this->dateTime($this->dateTime)) {
349
            $msg = "DateTime must be a valid date/time";
350
            return false;
351
        }
352
        if (null != $this->dateTimeOffset && $this->dateTimeOffset !== $this->dateTime($this->dateTimeOffset)) {
353
            $msg = "DateTimeOffset must be a valid date/time";
354
            return false;
355
        }
356
357
        return true;
358
    }
359
}
360