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

GInlineExpressionsTrait::setDateTime()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 2
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 View Code Duplication
    public function setString($string)
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...
85
    {
86
        $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...
87
        if (null != $string && !is_string($string)) {
88
            $msg = "String must be a string";
89
            throw new \InvalidArgumentException($msg);
90
        }
91
        $this->string = $string;
92
        return $this;
93
    }
94
95
    /**
96
     * Gets as binary
97
     *
98
     * @return mixed
99
     */
100
    public function getBinary()
101
    {
102
        return $this->binary;
103
    }
104
105
    /**
106
     * Sets a new binary
107
     *
108
     * @param mixed $binary
109
     * @return self
110
     */
111
    public function setBinary($binary)
112
    {
113
        $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...
114
        if (null != $binary && !$this->hexBinary($binary)) {
115
            $msg = "Binary must be hexadecimal";
116
            throw new \InvalidArgumentException($msg);
117
        }
118
        $this->binary = $binary;
119
        return $this;
120
    }
121
122
    /**
123
     * Gets as int
124
     *
125
     * @return integer
126
     */
127
    public function getInt()
128
    {
129
        return $this->int;
130
    }
131
132
    /**
133
     * Sets a new int
134
     *
135
     * @param integer $int
136
     * @return self
137
     */
138
    public function setInt($int)
139
    {
140
        $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...
141
        if (null != $int && $int !== intval($int)) {
142
            $msg = "Integer must be integral";
143
            throw new \InvalidArgumentException($msg);
144
        }
145
        $this->int = $int;
146
        return $this;
147
    }
148
149
    /**
150
     * Gets as float
151
     *
152
     * @return float
153
     */
154
    public function getFloat()
155
    {
156
        return $this->float;
157
    }
158
159
    /**
160
     * Sets a new float
161
     *
162
     * @param float $float
163
     * @return self
164
     */
165 View Code Duplication
    public function setFloat($float)
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...
166
    {
167
        $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...
168
        if (null != $float && $float !== floatval($float)) {
169
            $msg = "Float must be floating-point";
170
            throw new \InvalidArgumentException($msg);
171
        }
172
        $this->float = $float;
173
        return $this;
174
    }
175
176
    /**
177
     * Gets as guid
178
     *
179
     * @return string
180
     */
181
    public function getGuid()
182
    {
183
        return $this->guid;
184
    }
185
186
    /**
187
     * Sets a new guid
188
     *
189
     * @param string $guid
190
     * @return self
191
     */
192 View Code Duplication
    public function setGuid($guid)
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...
193
    {
194
        $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...
195
        if (null != $guid && !$this->isTGuidLiteralValid($guid)) {
196
            $msg = "Guid must be valid GUID";
197
            throw new \InvalidArgumentException($msg);
198
        }
199
        $this->guid = $guid;
200
        return $this;
201
    }
202
203
    /**
204
     * Gets as decimal
205
     *
206
     * @return float
207
     */
208
    public function getDecimal()
209
    {
210
        return $this->decimal;
211
    }
212
213
    /**
214
     * Sets a new decimal
215
     *
216
     * @param float $decimal
217
     * @return self
218
     */
219 View Code Duplication
    public function setDecimal($decimal)
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...
220
    {
221
        $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...
222
        if (null != $decimal && $decimal !== floatval($decimal)) {
223
            $msg = "Decimal must be decimal";
224
            throw new \InvalidArgumentException($msg);
225
        }
226
        $this->decimal = $decimal;
227
        return $this;
228
    }
229
230
    /**
231
     * Gets as bool
232
     *
233
     * @return boolean
234
     */
235
    public function getBool()
236
    {
237
        return $this->bool;
238
    }
239
240
    /**
241
     * Sets a new bool
242
     *
243
     * @param boolean $bool
244
     * @return self
245
     */
246
    public function setBool($bool)
247
    {
248
        $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...
249
        if (null != $bool && $bool !== boolval($bool)) {
250
            $msg = "Bool must be boolean";
251
            throw new \InvalidArgumentException($msg);
252
        }
253
        $this->bool = $bool;
254
        return $this;
255
    }
256
257
    /**
258
     * Gets as dateTime
259
     *
260
     * @return \DateTime
261
     */
262
    public function getDateTime()
263
    {
264
        return $this->dateTime;
265
    }
266
267
    /**
268
     * Sets a new dateTime
269
     *
270
     * @param \DateTime $dateTime
271
     * @return self
272
     */
273
    public function setDateTime(\DateTime $dateTime)
274
    {
275
        $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...
276
        if (null != $dateTime && $dateTime !== $this->dateTime($dateTime)) {
277
            $msg = "DateTime must be a valid date/time";
278
            throw new \InvalidArgumentException($msg);
279
        }
280
        $this->dateTime = $dateTime;
281
        return $this;
282
    }
283
284
    /**
285
     * Gets as dateTimeOffset
286
     *
287
     * @return \DateTime
288
     */
289
    public function getDateTimeOffset()
290
    {
291
        return $this->dateTimeOffset;
292
    }
293
294
    /**
295
     * Sets a new dateTimeOffset
296
     *
297
     * @param \DateTime $dateTimeOffset
298
     * @return self
299
     */
300
    public function setDateTimeOffset(\DateTime $dateTimeOffset)
301
    {
302
        $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...
303
        if (null != $dateTimeOffset && $dateTimeOffset !== $this->dateTime($dateTimeOffset)) {
304
            $msg = "DateTimeOffset must be a valid date/time";
305
            throw new \InvalidArgumentException($msg);
306
        }
307
        $this->dateTimeOffset = $dateTimeOffset;
308
        return $this;
309
    }
310
311
    /**
312
     * Gets as enum
313
     *
314
     * @return string
315
     */
316
    public function getEnum()
317
    {
318
        return $this->enum;
319
    }
320
321
    /**
322
     * Sets a new enum
323
     *
324
     * @param string $enum
325
     * @return self
326
     */
327 View Code Duplication
    public function setEnum($enum)
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...
328
    {
329
        $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...
330
        if (null != $enum && !$this->isTQualifiedNameValid($enum)) {
331
            $msg = "Enum must be a valid TQualifiedName";
332
            throw new \InvalidArgumentException($msg);
333
        }
334
        $this->enum = $enum;
335
        return $this;
336
    }
337
338
    /**
339
     * Gets as path
340
     *
341
     * @return string
342
     */
343
    public function getPath()
344
    {
345
        return $this->path;
346
    }
347
348
    /**
349
     * Sets a new path
350
     *
351
     * @param string $path
352
     * @return self
353
     */
354 View Code Duplication
    public function setPath($path)
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...
355
    {
356
        $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...
357
        if (null != $path && !$this->isTQualifiedNameValid($path)) {
358
            $msg = "Path must be a valid TQualifiedName";
359
            throw new \InvalidArgumentException($msg);
360
        }
361
        $this->path = $path;
362
        return $this;
363
    }
364
365
    public function isGInlineExpressionsValid(&$msg = null)
366
    {
367
        if (null != $this->string && !is_string($this->string)) {
368
            $msg = "String must be a string";
369
            return false;
370
        }
371
        if (null != $this->binary && !$this->hexBinary($this->binary)) {
372
            $msg = "Binary must be hexadecimal";
373
            return false;
374
        }
375
        if (null != $this->int && $this->int !== intval($this->int)) {
376
            $msg = "Integer must be integral";
377
            return false;
378
        }
379
        if (null != $this->float && $this->float !== floatval($this->float)) {
380
            $msg = "Float must be floating-point";
381
            return false;
382
        }
383 View Code Duplication
        if (null != $this->guid && !$this->isTGuidLiteralValid($this->guid)) {
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...
384
            $msg = "Guid must be valid GUID";
385
            return false;
386
        }
387
        if (null != $this->bool && $this->bool !== boolval($this->bool)) {
388
            $msg = "Bool must be boolean";
389
            return false;
390
        }
391
        if (null != $this->decimal && $this->decimal !== floatval($this->decimal)) {
392
            $msg = "Decimal must be decimal";
393
            return false;
394
        }
395 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...
396
            $msg = "Enum must be a valid TQualifiedName";
397
            return false;
398
        }
399 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...
400
            $msg = "Path must be a valid TQualifiedName";
401
            return false;
402
        }
403
        if (null != $this->dateTime && $this->dateTime !== $this->dateTime($this->dateTime)) {
404
            $msg = "DateTime must be a valid date/time";
405
            return false;
406
        }
407
        if (null != $this->dateTimeOffset && $this->dateTimeOffset !== $this->dateTime($this->dateTimeOffset)) {
408
            $msg = "DateTimeOffset must be a valid date/time";
409
            return false;
410
        }
411
412
        return true;
413
    }
414
}
415