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

TFunctionType::unsetCommandText()   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 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TCommandTextTrait;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TParameterTypeSemanticsTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TSimpleIdentifierTrait;
9
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\IsOKTraits\TUndottedIdentifierTrait;
10
11
/**
12
 * Class representing TFunctionType
13
 *
14
 *
15
 * XSD Type: TFunction
16
 */
17
class TFunctionType extends IsOK
18
{
19
    use TUndottedIdentifierTrait, TSimpleIdentifierTrait, TParameterTypeSemanticsTrait, TCommandTextTrait;
20
    /**
21
     * @property string $name
22
     */
23
    private $name = null;
24
25
    /**
26
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionReturnTypeType[] $returnType
27
     */
28
    private $returnType = [];
29
30
    /**
31
     * @property boolean $aggregate
32
     */
33
    private $aggregate = null;
34
35
    /**
36
     * @property boolean $builtIn
37
     */
38
    private $builtIn = null;
39
40
    /**
41
     * @property string $storeFunctionName
42
     */
43
    private $storeFunctionName = null;
44
45
    /**
46
     * @property boolean $niladicFunction
47
     */
48
    private $niladicFunction = null;
49
50
    /**
51
     * @property boolean $isComposable
52
     */
53
    private $isComposable = null;
54
55
    /**
56
     * @property string $parameterTypeSemantics
57
     */
58
    private $parameterTypeSemantics = "AllowImplicitConversion";
59
60
    /**
61
     * @property string $schema
62
     */
63
    private $schema = null;
64
65
    /**
66
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
67
     */
68
    private $documentation = null;
69
70
    /**
71
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TParameterType[] $parameter
72
     */
73
    private $parameter = [];
74
75
    /**
76
     * @property string[] $commandText
77
     */
78
    private $commandText = [];
79
80
    /**
81
     * Gets as name
82
     *
83
     * @return string
84
     */
85
    public function getName()
86
    {
87
        return $this->name;
88
    }
89
90
    /**
91
     * Sets a new name
92
     *
93
     * @param string $name
94
     * @return self
95
     */
96 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...
97
    {
98
        $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...
99
        if (!$this->isStringNotNullOrEmpty($name)) {
100
            $msg = "Name cannot be null or empty";
101
            throw new \InvalidArgumentException($msg);
102
        }
103
        if (!$this->isTUndottedIdentifierValid($name)) {
104
            $msg = "Name must be a valid TUndottedIdentifier";
105
            throw new \InvalidArgumentException($msg);
106
        }
107
        $this->name = $name;
108
        return $this;
109
    }
110
111
    /**
112
     * Adds as returnType
113
     *
114
     * @return self
115
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionReturnTypeType $returnType
116
     */
117 View Code Duplication
    public function addToReturnType(TFunctionReturnTypeType $returnType)
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...
118
    {
119
        $msg = null;
120
        if (!$returnType->isOK($msg)) {
121
            throw new \InvalidArgumentException($msg);
122
        }
123
        $this->returnType[] = $returnType;
124
        return $this;
125
    }
126
127
    /**
128
     * isset returnType
129
     *
130
     * @param scalar $index
131
     * @return boolean
132
     */
133
    public function issetReturnType($index)
134
    {
135
        return isset($this->returnType[$index]);
136
    }
137
138
    /**
139
     * unset returnType
140
     *
141
     * @param scalar $index
142
     * @return void
143
     */
144
    public function unsetReturnType($index)
145
    {
146
        unset($this->returnType[$index]);
147
    }
148
149
    /**
150
     * Gets as returnType
151
     *
152
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionReturnTypeType[]
153
     */
154
    public function getReturnType()
155
    {
156
        return $this->returnType;
157
    }
158
159
    /**
160
     * Sets a new returnType
161
     *
162
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionReturnTypeType[] $returnType
163
     * @return self
164
     */
165 View Code Duplication
    public function setReturnType(array $returnType)
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;
168
        if (!$this->isValidArrayOK(
169
            $returnType,
170
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionReturnTypeType',
171
            $msg
172
        )) {
173
            throw new \InvalidArgumentException($msg);
174
        }
175
        $this->returnType = $returnType;
176
        return $this;
177
    }
178
179
    /**
180
     * Gets as aggregate
181
     *
182
     * @return boolean
183
     */
184
    public function getAggregate()
185
    {
186
        return $this->aggregate;
187
    }
188
189
    /**
190
     * Sets a new aggregate
191
     *
192
     * @param boolean $aggregate
193
     * @return self
194
     */
195
    public function setAggregate($aggregate)
196
    {
197
        $this->aggregate = boolval($aggregate);
198
        return $this;
199
    }
200
201
    /**
202
     * Gets as builtIn
203
     *
204
     * @return boolean
205
     */
206
    public function getBuiltIn()
207
    {
208
        return $this->builtIn;
209
    }
210
211
    /**
212
     * Sets a new builtIn
213
     *
214
     * @param boolean $builtIn
215
     * @return self
216
     */
217
    public function setBuiltIn($builtIn)
218
    {
219
        $this->builtIn = boolval($builtIn);
220
        return $this;
221
    }
222
223
    /**
224
     * Gets as storeFunctionName
225
     *
226
     * @return string
227
     */
228
    public function getStoreFunctionName()
229
    {
230
        return $this->storeFunctionName;
231
    }
232
233
    /**
234
     * Sets a new storeFunctionName
235
     *
236
     * @param string $storeFunctionName
237
     * @return self
238
     */
239
    public function setStoreFunctionName($storeFunctionName)
240
    {
241
        $this->storeFunctionName = $storeFunctionName;
242
        return $this;
243
    }
244
245
    /**
246
     * Gets as niladicFunction
247
     *
248
     * @return boolean
249
     */
250
    public function getNiladicFunction()
251
    {
252
        return $this->niladicFunction;
253
    }
254
255
    /**
256
     * Sets a new niladicFunction
257
     *
258
     * @param boolean $niladicFunction
259
     * @return self
260
     */
261
    public function setNiladicFunction($niladicFunction)
262
    {
263
        $this->niladicFunction = boolval($niladicFunction);
264
        return $this;
265
    }
266
267
    /**
268
     * Gets as isComposable
269
     *
270
     * @return boolean
271
     */
272
    public function getIsComposable()
273
    {
274
        return $this->isComposable;
275
    }
276
277
    /**
278
     * Sets a new isComposable
279
     *
280
     * @param boolean $isComposable
281
     * @return self
282
     */
283
    public function setIsComposable($isComposable)
284
    {
285
        $this->isComposable = boolval($isComposable);
286
        return $this;
287
    }
288
289
    /**
290
     * Gets as parameterTypeSemantics
291
     *
292
     * @return string
293
     */
294
    public function getParameterTypeSemantics()
295
    {
296
        return $this->parameterTypeSemantics;
297
    }
298
299
    /**
300
     * Sets a new parameterTypeSemantics
301
     *
302
     * @param string $parameterTypeSemantics
303
     * @return self
304
     */
305
    public function setParameterTypeSemantics($parameterTypeSemantics)
306
    {
307
        $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...
308
        if (null != $parameterTypeSemantics && !$this->isStringNotNullOrEmpty($parameterTypeSemantics)) {
309
            $msg = "Parameter type semantics cannot be empty";
310
            throw new \InvalidArgumentException($msg);
311
        }
312
        if (null != $parameterTypeSemantics
313
            && !$this->isTParameterTypeSemanticsValid($parameterTypeSemantics)) {
314
            $msg = "Parameter type semantics must be a valid TParameterTypeSemantics";
315
            throw new \InvalidArgumentException($msg);
316
        }
317
        $this->parameterTypeSemantics = $parameterTypeSemantics;
318
        return $this;
319
    }
320
321
    /**
322
     * Gets as schema
323
     *
324
     * @return string
325
     */
326
    public function getSchema()
327
    {
328
        return $this->schema;
329
    }
330
331
    /**
332
     * Sets a new schema
333
     *
334
     * @param string $schema
335
     * @return self
336
     */
337
    public function setSchema($schema)
338
    {
339
        $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...
340
        if (null != $schema && !$this->isStringNotNullOrEmpty($schema)) {
341
            $msg = "Schema cannot be empty";
342
            throw new \InvalidArgumentException($msg);
343
        }
344
        if (null != $schema && !$this->isTSimpleIdentifierValid($schema)) {
345
            $msg = "Schema must be a valid TSimpleIdentifier";
346
            throw new \InvalidArgumentException($msg);
347
        }
348
        $this->schema = $schema;
349
        return $this;
350
    }
351
352
    /**
353
     * Gets as documentation
354
     *
355
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType
356
     */
357
    public function getDocumentation()
358
    {
359
        return $this->documentation;
360
    }
361
362
    /**
363
     * Sets a new documentation
364
     *
365
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation
366
     * @return self
367
     */
368 View Code Duplication
    public function setDocumentation(TDocumentationType $documentation)
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...
369
    {
370
        $msg = null;
371
        if (!$documentation->isOK($msg)) {
372
            throw new \InvalidArgumentException($msg);
373
        }
374
        $this->documentation = $documentation;
375
        return $this;
376
    }
377
378
    /**
379
     * Adds as parameter
380
     *
381
     * @return self
382
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TParameterType $parameter
383
     */
384 View Code Duplication
    public function addToParameter(TParameterType $parameter)
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...
385
    {
386
        $msg = null;
387
        if (!$parameter->isOK($msg)) {
388
            throw new \InvalidArgumentException($msg);
389
        }
390
        $this->parameter[] = $parameter;
391
        return $this;
392
    }
393
394
    /**
395
     * isset parameter
396
     *
397
     * @param scalar $index
398
     * @return boolean
399
     */
400
    public function issetParameter($index)
401
    {
402
        return isset($this->parameter[$index]);
403
    }
404
405
    /**
406
     * unset parameter
407
     *
408
     * @param scalar $index
409
     * @return void
410
     */
411
    public function unsetParameter($index)
412
    {
413
        unset($this->parameter[$index]);
414
    }
415
416
    /**
417
     * Gets as parameter
418
     *
419
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TParameterType[]
420
     */
421
    public function getParameter()
422
    {
423
        return $this->parameter;
424
    }
425
426
    /**
427
     * Sets a new parameter
428
     *
429
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TParameterType[] $parameter
430
     * @return self
431
     */
432 View Code Duplication
    public function setParameter(array $parameter)
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...
433
    {
434
        $msg = null;
435
        if (!$this->isValidArrayOK(
436
            $parameter,
437
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TParameterType',
438
            $msg
439
        )) {
440
            throw new \InvalidArgumentException($msg);
441
        }
442
        $this->parameter = $parameter;
443
        return $this;
444
    }
445
446
    /**
447
     * Adds as commandText
448
     *
449
     * @return self
450
     * @param string $commandText
451
     */
452 View Code Duplication
    public function addToCommandText($commandText)
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...
453
    {
454
        $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...
455
        if (!$this->isTCommandTextValid($commandText)) {
456
            $msg = "All command text entries must be valid TCommandText";
457
            throw new \InvalidArgumentException($msg);
458
        }
459
        $this->commandText[] = $commandText;
460
        return $this;
461
    }
462
463
    /**
464
     * isset commandText
465
     *
466
     * @param scalar $index
467
     * @return boolean
468
     */
469
    public function issetCommandText($index)
470
    {
471
        return isset($this->commandText[$index]);
472
    }
473
474
    /**
475
     * unset commandText
476
     *
477
     * @param scalar $index
478
     * @return void
479
     */
480
    public function unsetCommandText($index)
481
    {
482
        unset($this->commandText[$index]);
483
    }
484
485
    /**
486
     * Gets as commandText
487
     *
488
     * @return string[]
489
     */
490
    public function getCommandText()
491
    {
492
        return $this->commandText;
493
    }
494
495
    /**
496
     * Sets a new commandText
497
     *
498
     * @param string $commandText
499
     * @return self
500
     */
501 View Code Duplication
    public function setCommandText(array $commandText)
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...
502
    {
503
        foreach ($commandText as $command) {
504
            if (!$this->isTCommandTextValid($command)) {
505
                $msg = "All command text entries must be valid TCommandText";
506
                throw new \InvalidArgumentException($msg);
507
            }
508
        }
509
        $this->commandText = $commandText;
510
        return $this;
511
    }
512
513
    public function isOK(&$msg = null)
514
    {
515
        if (!$this->isStringNotNullOrEmpty($this->name)) {
516
            $msg = "Name cannot be null or empty";
517
            return false;
518
        }
519
        if (null != $this->storeFunctionName && !$this->isStringNotNullOrEmpty($this->storeFunctionName)) {
520
            $msg = "Store function name cannot be empty";
521
            return false;
522
        }
523
        if (null != $this->parameterTypeSemantics && !$this->isStringNotNullOrEmpty($this->parameterTypeSemantics)) {
524
            $msg = "Parameter type semantics cannot be empty";
525
            return false;
526
        }
527
        if (null != $this->schema && !$this->isStringNotNullOrEmpty($this->schema)) {
528
            $msg = "Schema cannot be empty";
529
            return false;
530
        }
531
        foreach ($this->commandText as $command) {
532
            if (!$this->isTCommandTextValid($command)) {
533
                $msg = "All command text entries must be valid TCommandText";
534
                return false;
535
            }
536
        }
537
        if (!$this->isTUndottedIdentifierValid($this->name)) {
538
            $msg = "Name must be a valid TUndottedIdentifier";
539
            return false;
540
        }
541 View Code Duplication
        if (null != $this->schema && !$this->isTSimpleIdentifierValid($this->schema)) {
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...
542
            $msg = "Schema must be a valid TSimpleIdentifier";
543
            return false;
544
        }
545
        if (null != $this->parameterTypeSemantics
546
            && !$this->isTParameterTypeSemanticsValid($this->parameterTypeSemantics)) {
547
            $msg = "Parameter type semantics must be a valid TParameterTypeSemantics";
548
            return false;
549
        }
550
        if (!$this->isObjectNullOrOK($this->documentation, $msg)) {
551
            return false;
552
        }
553
        if (!$this->isValidArrayOK(
554
            $this->parameter,
555
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TParameterType',
556
            $msg
557
        )) {
558
            return false;
559
        }
560
        if (!$this->isValidArrayOK(
561
            $this->returnType,
562
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionReturnTypeType',
563
            $msg
564
        )) {
565
            return false;
566
        }
567
568
        return true;
569
    }
570
}
571