Test Failed
Push — master ( 0f618b...fb6850 )
by Alex
09:40
created

TEntityPropertyType::getName()   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\ssdl;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TPropertyTypeTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TSimpleIdentifierTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TStoreGeneratedPatternTrait;
9
10
/**
11
 * Class representing TEntityPropertyType
12
 *
13
 *
14
 * XSD Type: TEntityProperty
15
 */
16
class TEntityPropertyType extends IsOK
17
{
18
    use TSimpleIdentifierTrait, TPropertyTypeTrait, TStoreGeneratedPatternTrait, GEmptyElementExtensibilityTrait;
19
    /**
20
     * @property string $name
21
     */
22
    private $name = null;
23
24
    /**
25
     * @property string $type
26
     */
27
    private $type = null;
28
29
    /**
30
     * @property boolean $nullable
31
     */
32
    private $nullable = true;
33
34
    /**
35
     * @property string $defaultValue
36
     */
37
    private $defaultValue = null;
38
39
    /**
40
     * @property string $maxLength
41
     */
42
    private $maxLength = null;
43
44
    /**
45
     * @property boolean $fixedLength
46
     */
47
    private $fixedLength = null;
48
49
    /**
50
     * @property integer $precision
51
     */
52
    private $precision = null;
53
54
    /**
55
     * @property integer $scale
56
     */
57
    private $scale = null;
58
59
    /**
60
     * @property boolean $unicode
61
     */
62
    private $unicode = null;
63
64
    /**
65
     * @property string $collation
66
     */
67
    private $collation = null;
68
69
    /**
70
     * @property string $sRID
71
     */
72
    private $sRID = null;
73
74
    /**
75
     * @property string $storeGeneratedPattern
76
     */
77
    private $storeGeneratedPattern = null;
78
79
    /**
80
     * Gets as name
81
     *
82
     * @return string
83
     */
84
    public function getName()
85
    {
86
        return $this->name;
87
    }
88
89
    /**
90
     * Sets a new name
91
     *
92
     * @param string $name
93
     * @return self
94
     */
95 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...
96
    {
97
        $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...
98
        if (!$this->isStringNotNullOrEmpty($name)) {
99
            $msg = "Name cannot be null or empty";
100
            throw new \InvalidArgumentException($msg);
101
        }
102
        if (!$this->isTSimpleIdentifierValid($name)) {
103
            $msg = "Name must be valid TSimpleIdentifier";
104
            throw new \InvalidArgumentException($msg);
105
        }
106
        $this->name = $name;
107
        return $this;
108
    }
109
110
    /**
111
     * Gets as type
112
     *
113
     * @return string
114
     */
115
    public function getType()
116
    {
117
        return $this->type;
118
    }
119
120
    /**
121
     * Sets a new type
122
     *
123
     * @param string $type
124
     * @return self
125
     */
126 View Code Duplication
    public function setType($type)
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...
127
    {
128
        $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...
129
        if (!$this->isStringNotNullOrEmpty($type)) {
130
            $msg = "Type cannot be null or empty";
131
            throw new \InvalidArgumentException($msg);
132
        }
133
        if (!$this->isTPropertyTypeValid($type)) {
134
            $msg = "Type must be valid TPropertyType";
135
            throw new \InvalidArgumentException($msg);
136
        }
137
        $this->type = $type;
138
        return $this;
139
    }
140
141
    /**
142
     * Gets as nullable
143
     *
144
     * @return boolean
145
     */
146
    public function getNullable()
147
    {
148
        return $this->nullable;
149
    }
150
151
    /**
152
     * Sets a new nullable
153
     *
154
     * @param boolean $nullable
155
     * @return self
156
     */
157
    public function setNullable($nullable)
158
    {
159
        $this->nullable = boolval($nullable);
160
        return $this;
161
    }
162
163
    /**
164
     * Gets as defaultValue
165
     *
166
     * @return string
167
     */
168
    public function getDefaultValue()
169
    {
170
        return $this->defaultValue;
171
    }
172
173
    /**
174
     * Sets a new defaultValue
175
     *
176
     * @param string $defaultValue
177
     * @return self
178
     */
179 View Code Duplication
    public function setDefaultValue($defaultValue)
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...
180
    {
181
        if (null != $defaultValue && !$this->isStringNotNullOrEmpty($defaultValue)) {
182
            $msg = "Default value cannot be empty";
183
            throw new \InvalidArgumentException($msg);
184
        }
185
        $this->defaultValue = $defaultValue;
186
        return $this;
187
    }
188
189
    /**
190
     * Gets as maxLength
191
     *
192
     * @return string
193
     */
194
    public function getMaxLength()
195
    {
196
        return $this->maxLength;
197
    }
198
199
    /**
200
     * Sets a new maxLength
201
     *
202
     * @param string $maxLength
203
     * @return self
204
     */
205
    public function setMaxLength($maxLength)
206
    {
207
        if (null != $maxLength && !(is_numeric($maxLength) && 0 < $maxLength)) {
208
            $msg = "Max length must be positive and numeric";
209
            throw new \InvalidArgumentException($msg);
210
        }
211
        $this->maxLength = $maxLength;
212
        return $this;
213
    }
214
215
    /**
216
     * Gets as fixedLength
217
     *
218
     * @return boolean
219
     */
220
    public function getFixedLength()
221
    {
222
        return $this->fixedLength;
223
    }
224
225
    /**
226
     * Sets a new fixedLength
227
     *
228
     * @param boolean $fixedLength
229
     * @return self
230
     */
231
    public function setFixedLength($fixedLength)
232
    {
233
        $this->fixedLength = boolval($fixedLength);
234
        return $this;
235
    }
236
237
    /**
238
     * Gets as precision
239
     *
240
     * @return integer
241
     */
242
    public function getPrecision()
243
    {
244
        return $this->precision;
245
    }
246
247
    /**
248
     * Sets a new precision
249
     *
250
     * @param integer $precision
251
     * @return self
252
     */
253 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...
254
    {
255
        if (null != $precision && !(is_numeric($precision) && 0 < $precision)) {
256
            $msg = "Precision must be positive and numeric";
257
            throw new \InvalidArgumentException($msg);
258
        }
259
        $this->precision = $precision;
260
        return $this;
261
    }
262
263
    /**
264
     * Gets as scale
265
     *
266
     * @return integer
267
     */
268
    public function getScale()
269
    {
270
        return $this->scale;
271
    }
272
273
    /**
274
     * Sets a new scale
275
     *
276
     * @param integer $scale
277
     * @return self
278
     */
279 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...
280
    {
281
        if (null != $scale && !(is_numeric($scale) && 0 < $scale)) {
282
            $msg = "Scale must be positive and numeric";
283
            throw new \InvalidArgumentException($msg);
284
        }
285
        $this->scale = $scale;
286
        return $this;
287
    }
288
289
    /**
290
     * Gets as unicode
291
     *
292
     * @return boolean
293
     */
294
    public function getUnicode()
295
    {
296
        return $this->unicode;
297
    }
298
299
    /**
300
     * Sets a new unicode
301
     *
302
     * @param boolean $unicode
303
     * @return self
304
     */
305
    public function setUnicode($unicode)
306
    {
307
        $this->unicode = boolval($unicode);
308
        return $this;
309
    }
310
311
    /**
312
     * Gets as collation
313
     *
314
     * @return string
315
     */
316
    public function getCollation()
317
    {
318
        return $this->collation;
319
    }
320
321
    /**
322
     * Sets a new collation
323
     *
324
     * @param string $collation
325
     * @return self
326
     */
327 View Code Duplication
    public function setCollation($collation)
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
        if (null != $collation && !$this->isStringNotNullOrEmpty($collation)) {
330
            $msg = "Collation cannot be empty";
331
            throw new \InvalidArgumentException($msg);
332
        }
333
        $this->collation = $collation;
334
        return $this;
335
    }
336
337
    /**
338
     * Gets as sRID
339
     *
340
     * @return string
341
     */
342
    public function getSRID()
343
    {
344
        return $this->sRID;
345
    }
346
347
    /**
348
     * Sets a new sRID
349
     *
350
     * @param string $sRID
351
     * @return self
352
     */
353 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...
354
    {
355
        if (null != $sRID && !$this->isStringNotNullOrEmpty($sRID)) {
356
            $msg = "SRID cannot be empty";
357
            throw new \InvalidArgumentException($msg);
358
        }
359
        $this->sRID = $sRID;
360
        return $this;
361
    }
362
363
    /**
364
     * Gets as storeGeneratedPattern
365
     *
366
     * @return string
367
     */
368
    public function getStoreGeneratedPattern()
369
    {
370
        return $this->storeGeneratedPattern;
371
    }
372
373
    /**
374
     * Sets a new storeGeneratedPattern
375
     *
376
     * @param string $storeGeneratedPattern
377
     * @return self
378
     */
379
    public function setStoreGeneratedPattern($storeGeneratedPattern)
380
    {
381
        if (null != $storeGeneratedPattern && !$this->isStringNotNullOrEmpty($storeGeneratedPattern)) {
382
            $msg = "Store generated pattern cannot be empty";
383
            throw new \InvalidArgumentException($msg);
384
        }
385
        $this->storeGeneratedPattern = $storeGeneratedPattern;
386
        return $this;
387
    }
388
389
    public function isOK(&$msg = null)
390
    {
391
        if (!$this->isStringNotNullOrEmpty($this->name)) {
392
            $msg = "Name cannot be null or empty";
393
            return false;
394
        }
395
        if (!$this->isStringNotNullOrEmpty($this->type)) {
396
            $msg = "Type cannot be null or empty";
397
            return false;
398
        }
399 View Code Duplication
        if (null != $this->defaultValue && !$this->isStringNotNullOrEmpty($this->defaultValue)) {
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 = "Default value cannot be empty";
401
            return false;
402
        }
403 View Code Duplication
        if (null != $this->maxLength && !(is_numeric($this->maxLength) && 0 < $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...
404
            $msg = "Max length must be positive and numeric";
405
            return false;
406
        }
407 View Code Duplication
        if (null != $this->precision && !(is_numeric($this->precision) && 0 < $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...
408
            $msg = "Precision must be positive and numeric";
409
            return false;
410
        }
411 View Code Duplication
        if (null != $this->scale && !(is_numeric($this->scale) && 0 < $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...
412
            $msg = "Scale must be positive and numeric";
413
            return false;
414
        }
415 View Code Duplication
        if (null != $this->collation && !$this->isStringNotNullOrEmpty($this->collation)) {
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...
416
            $msg = "Collation cannot be empty";
417
            return false;
418
        }
419 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...
420
            $msg = "SRID cannot be empty";
421
            return false;
422
        }
423
        if (null != $this->storeGeneratedPattern && !$this->isStringNotNullOrEmpty($this->storeGeneratedPattern)) {
424
            $msg = "Store generated pattern cannot be empty";
425
            return false;
426
        }
427
428
        if (!$this->isTSimpleIdentifierValid($this->name)) {
429
            $msg = "Name must be valid TSimpleIdentifier";
430
            return false;
431
        }
432
        if (!$this->isTPropertyTypeValid($this->type)) {
433
            $msg = "Type must be valid TPropertyType";
434
            return false;
435
        }
436
        if (null != $this->storeGeneratedPattern
437
            && !$this->isTStoreGeneratedPatternValid($this->storeGeneratedPattern)) {
438
            $msg = "Store generated pattern must be valid TStoreGeneratedPattern";
439
            return false;
440
        }
441
        if (!$this->isExtensibilityElementOK($msg)) {
442
            return false;
443
        }
444
445
        return true;
446
    }
447
}
448