Passed
Push — master ( 189420...0898fe )
by Alex
04:14
created

TApplyExpressionType::unsetArguments()   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;
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 TApplyExpressionType
11
 *
12
 *
13
 * XSD Type: TApplyExpression
14
 */
15
class TApplyExpressionType extends IsOK
16
{
17
    use IsOKToolboxTrait, TQualifiedNameTrait;
18
    /**
19
     * @property string $function
20
     */
21
    private $function = null;
22
23
    /**
24
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\AppliedFunctionAnonymousType[]
25
     * $appliedFunction
26
     */
27
    private $appliedFunction = [];
28
29
    /**
30
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\ArgumentsAnonymousType[]
31
     * $arguments
32
     */
33
    private $arguments = [];
34
35
    /**
36
     * Gets as function
37
     *
38
     * @return string
39
     */
40
    public function getFunction()
41
    {
42
        return $this->function;
43
    }
44
45
    /**
46
     * Sets a new function
47
     *
48
     * @param string $function
49
     * @return self
50
     */
51
    public function setFunction($function)
52
    {
53
        $this->function = $function;
54
        return $this;
55
    }
56
57
    /**
58
     * Adds as appliedFunction
59
     *
60
     * @return self
61
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\AppliedFunctionAnonymousType
62
     * $appliedFunction
63
     */
64
    public function addToAppliedFunction(TApplyExpressionType\AppliedFunctionAnonymousType $appliedFunction)
65
    {
66
        $this->appliedFunction[] = $appliedFunction;
67
        return $this;
68
    }
69
70
    /**
71
     * isset appliedFunction
72
     *
73
     * @param scalar $index
74
     * @return boolean
75
     */
76
    public function issetAppliedFunction($index)
77
    {
78
        return isset($this->appliedFunction[$index]);
79
    }
80
81
    /**
82
     * unset appliedFunction
83
     *
84
     * @param scalar $index
85
     * @return void
86
     */
87
    public function unsetAppliedFunction($index)
88
    {
89
        unset($this->appliedFunction[$index]);
90
    }
91
92
    /**
93
     * Gets as appliedFunction
94
     *
95
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\AppliedFunctionAnonymousType[]
96
     */
97
    public function getAppliedFunction()
98
    {
99
        return $this->appliedFunction;
100
    }
101
102
    /**
103
     * Sets a new appliedFunction
104
     *
105
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\AppliedFunctionAnonymousType[]
106
     * $appliedFunction
107
     * @return self
108
     */
109
    public function setAppliedFunction(array $appliedFunction)
110
    {
111
        $this->appliedFunction = $appliedFunction;
112
        return $this;
113
    }
114
115
    /**
116
     * Adds as arguments
117
     *
118
     * @return self
119
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\ArgumentsAnonymousType $arguments
120
     */
121
    public function addToArguments(TApplyExpressionType\ArgumentsAnonymousType $arguments)
122
    {
123
        $this->arguments[] = $arguments;
124
        return $this;
125
    }
126
127
    /**
128
     * isset arguments
129
     *
130
     * @param scalar $index
131
     * @return boolean
132
     */
133
    public function issetArguments($index)
134
    {
135
        return isset($this->arguments[$index]);
136
    }
137
138
    /**
139
     * unset arguments
140
     *
141
     * @param scalar $index
142
     * @return void
143
     */
144
    public function unsetArguments($index)
145
    {
146
        unset($this->arguments[$index]);
147
    }
148
149
    /**
150
     * Gets as arguments
151
     *
152
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\ArgumentsAnonymousType[]
153
     */
154
    public function getArguments()
155
    {
156
        return $this->arguments;
157
    }
158
159
    /**
160
     * Sets a new arguments
161
     *
162
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\ArgumentsAnonymousType[] $arguments
163
     * @return self
164
     */
165
    public function setArguments(array $arguments)
166
    {
167
        $this->arguments = $arguments;
168
        return $this;
169
    }
170
171
    public function isOK(&$msg = null)
172
    {
173
        if (null != $this->function && !$this->isTQualifiedNameValid($this->function)) {
174
            $msg = "Function must be a valid TQualifiedName";
175
            return false;
176
        }
177
178
        if (!$this->isValidArrayOK(
179
            $this->appliedFunction,
180
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\AppliedFunctionAnonymousType',
181
            $msg
182
        )) {
183
            return false;
184
        }
185
        if (!$this->isValidArrayOK(
186
            $this->arguments,
187
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType\ArgumentsAnonymousType',
188
            $msg
189
        )) {
190
            return false;
191
        }
192
        $count = (0 < count($this->appliedFunction) ? 1 : 0) + (0 < count($this->arguments) ? 1 : 0);
193
        if (1 != $count) {
194
            $msg = "Exactly one of applied function array and arguments array must be non-empty";
195
            return false;
196
        }
197
198
        return true;
199
    }
200
}
201