1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\MetadataV3\edm; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\IsOK; |
6
|
|
|
use AlgoWeb\ODataMetadata\IsOKTraits\IsOKToolboxTrait; |
7
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TQualifiedNameTrait; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class representing TFunctionReferenceExpressionType |
11
|
|
|
* |
12
|
|
|
* |
13
|
|
|
* XSD Type: TFunctionReferenceExpression |
14
|
|
|
*/ |
15
|
|
View Code Duplication |
class TFunctionReferenceExpressionType extends IsOK |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
use IsOKToolboxTrait, TQualifiedNameTrait; |
18
|
|
|
/** |
19
|
|
|
* @property string $function |
20
|
|
|
*/ |
21
|
|
|
private $function = null; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @property |
25
|
|
|
* \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType[] |
26
|
|
|
* $parameter |
27
|
|
|
*/ |
28
|
|
|
private $parameter = []; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Gets as function |
32
|
|
|
* |
33
|
|
|
* @return string |
34
|
|
|
*/ |
35
|
|
|
public function getFunction() |
36
|
|
|
{ |
37
|
|
|
return $this->function; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Sets a new function |
42
|
|
|
* |
43
|
|
|
* @param string $function |
44
|
|
|
* @return self |
45
|
|
|
*/ |
46
|
|
|
public function setFunction($function) |
47
|
|
|
{ |
48
|
|
|
$this->function = $function; |
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Adds as parameter |
54
|
|
|
* |
55
|
|
|
* @return self |
56
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType |
57
|
|
|
* $parameter |
58
|
|
|
*/ |
59
|
|
|
public function addToParameter(TFunctionReferenceExpressionType\ParameterAnonymousType $parameter) |
60
|
|
|
{ |
61
|
|
|
$this->parameter[] = $parameter; |
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* isset parameter |
67
|
|
|
* |
68
|
|
|
* @param scalar $index |
69
|
|
|
* @return boolean |
70
|
|
|
*/ |
71
|
|
|
public function issetParameter($index) |
72
|
|
|
{ |
73
|
|
|
return isset($this->parameter[$index]); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* unset parameter |
78
|
|
|
* |
79
|
|
|
* @param scalar $index |
80
|
|
|
* @return void |
81
|
|
|
*/ |
82
|
|
|
public function unsetParameter($index) |
83
|
|
|
{ |
84
|
|
|
unset($this->parameter[$index]); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Gets as parameter |
89
|
|
|
* |
90
|
|
|
* @return |
91
|
|
|
* \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType[] |
92
|
|
|
*/ |
93
|
|
|
public function getParameter() |
94
|
|
|
{ |
95
|
|
|
return $this->parameter; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Sets a new parameter |
100
|
|
|
* |
101
|
|
|
* @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType[] |
102
|
|
|
* $parameter |
103
|
|
|
* @return self |
104
|
|
|
*/ |
105
|
|
|
public function setParameter(array $parameter) |
106
|
|
|
{ |
107
|
|
|
$this->parameter = $parameter; |
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
public function isOK(&$msg = null) |
112
|
|
|
{ |
113
|
|
|
if (!$this->isTQualifiedNameValid($this->function)) { |
114
|
|
|
$msg = "Function must be a valid TQualifiedName"; |
115
|
|
|
return false; |
116
|
|
|
} |
117
|
|
|
if (!$this->isValidArrayOK( |
118
|
|
|
$this->function, |
|
|
|
|
119
|
|
|
'\AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType\ParameterAnonymousType', |
120
|
|
|
$msg, |
121
|
|
|
1 |
122
|
|
|
)) { |
123
|
|
|
return false; |
124
|
|
|
} |
125
|
|
|
return true; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
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.