Completed
Push — master ( d2e6ed...f00d96 )
by Alex
10:33
created

TTypeAssertExpressionType::issetCollectionType()   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\Groups\TFacetAttributesTrait;
8
use AlgoWeb\ODataMetadata\MetadataV3\edm\IsOKTraits\TWrappedFunctionTypeTrait;
9
10
/**
11
 * Class representing TTypeAssertExpressionType
12
 *
13
 *
14
 * XSD Type: TTypeAssertExpression
15
 */
16
class TTypeAssertExpressionType extends IsOK
17
{
18
    use TFacetAttributesTrait, TWrappedFunctionTypeTrait;
19
    /**
20
     * @property string $type
21
     */
22
    private $type = null;
23
24
    /**
25
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType[] $operand
26
     */
27
    private $operand = [];
28
29
    /**
30
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] $collectionType
31
     */
32
    private $collectionType = [];
33
34
    /**
35
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] $referenceType
36
     */
37
    private $referenceType = [];
38
39
    /**
40
     * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
41
     */
42
    private $rowType = [];
43
44
    /**
45
     * Gets as type
46
     *
47
     * @return string
48
     */
49
    public function getType()
50
    {
51
        return $this->type;
52
    }
53
54
    /**
55
     * Sets a new type
56
     *
57
     * @param string $type
58
     * @return self
59
     */
60
    public function setType($type)
61
    {
62
        if (null != $type && !$this->isTWrappedFunctionTypeValid($type)) {
63
            $msg = "Type must be a valid TWrappedFunctionType";
64
            throw new \InvalidArgumentException($msg);
65
        }
66
        $this->type = $type;
67
        return $this;
68
    }
69
70
    /**
71
     * Adds as operand
72
     *
73
     * @return self
74
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType $operand
75
     */
76 View Code Duplication
    public function addToOperand(TOperandType $operand)
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...
77
    {
78
        $msg = null;
79
        if (!$operand->isOK($msg)) {
80
            throw new \InvalidArgumentException($msg);
81
        }
82
        $this->operand[] = $operand;
83
        return $this;
84
    }
85
86
    /**
87
     * isset operand
88
     *
89
     * @param scalar $index
90
     * @return boolean
91
     */
92
    public function issetOperand($index)
93
    {
94
        return isset($this->operand[$index]);
95
    }
96
97
    /**
98
     * unset operand
99
     *
100
     * @param scalar $index
101
     * @return void
102
     */
103
    public function unsetOperand($index)
104
    {
105
        unset($this->operand[$index]);
106
    }
107
108
    /**
109
     * Gets as operand
110
     *
111
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType[]
112
     */
113
    public function getOperand()
114
    {
115
        return $this->operand;
116
    }
117
118
    /**
119
     * Sets a new operand
120
     *
121
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType[] $operand
122
     * @return self
123
     */
124
    public function setOperand(array $operand)
125
    {
126
        if (!$this->isValidArrayOK($operand, '\AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType', $msg, 1)) {
127
            throw new \InvalidArgumentException($msg);
128
        }
129
        $this->operand = $operand;
130
        return $this;
131
    }
132
133
    /**
134
     * Adds as collectionType
135
     *
136
     * @return self
137
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType
138
     */
139
    public function addToCollectionType(TCollectionTypeType $collectionType)
140
    {
141
        $msg = null;
142
        if (!$collectionType->isOK($msg)) {
143
            throw new \InvalidArgumentException($msg);
144
        }
145
        $this->collectionType[] = $collectionType;
146
        return $this;
147
    }
148
149
    /**
150
     * isset collectionType
151
     *
152
     * @param scalar $index
153
     * @return boolean
154
     */
155
    public function issetCollectionType($index)
156
    {
157
        return isset($this->collectionType[$index]);
158
    }
159
160
    /**
161
     * unset collectionType
162
     *
163
     * @param scalar $index
164
     * @return void
165
     */
166
    public function unsetCollectionType($index)
167
    {
168
        unset($this->collectionType[$index]);
169
    }
170
171
    /**
172
     * Gets as collectionType
173
     *
174
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[]
175
     */
176
    public function getCollectionType()
177
    {
178
        return $this->collectionType;
179
    }
180
181
    /**
182
     * Sets a new collectionType
183
     *
184
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] $collectionType
185
     * @return self
186
     */
187
    public function setCollectionType(array $collectionType)
188
    {
189
        if (!$this->isValidArrayOK(
190
            $collectionType,
191
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType',
192
            $msg
193
        )) {
194
            throw new \InvalidArgumentException($msg);
195
        }
196
        $this->collectionType = $collectionType;
197
        return $this;
198
    }
199
200
    /**
201
     * Adds as referenceType
202
     *
203
     * @return self
204
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType
205
     */
206
    public function addToReferenceType(TReferenceTypeType $referenceType)
207
    {
208
        $msg = null;
209
        if (!$referenceType->isOK($msg)) {
210
            throw new \InvalidArgumentException($msg);
211
        }
212
        $this->referenceType[] = $referenceType;
213
        return $this;
214
    }
215
216
    /**
217
     * isset referenceType
218
     *
219
     * @param scalar $index
220
     * @return boolean
221
     */
222
    public function issetReferenceType($index)
223
    {
224
        return isset($this->referenceType[$index]);
225
    }
226
227
    /**
228
     * unset referenceType
229
     *
230
     * @param scalar $index
231
     * @return void
232
     */
233
    public function unsetReferenceType($index)
234
    {
235
        unset($this->referenceType[$index]);
236
    }
237
238
    /**
239
     * Gets as referenceType
240
     *
241
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[]
242
     */
243
    public function getReferenceType()
244
    {
245
        return $this->referenceType;
246
    }
247
248
    /**
249
     * Sets a new referenceType
250
     *
251
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] $referenceType
252
     * @return self
253
     */
254
    public function setReferenceType(array $referenceType)
255
    {
256
        if (!$this->isValidArrayOK(
257
            $referenceType,
258
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType',
259
            $msg
260
        )) {
261
            throw new \InvalidArgumentException($msg);
262
        }
263
        $this->referenceType = $referenceType;
264
        return $this;
265
    }
266
267
    /**
268
     * Adds as property
269
     *
270
     * @return self
271
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property
272
     */
273
    public function addToRowType(TPropertyType $property)
274
    {
275
        $msg = null;
276
        if (!$property->isOK($msg)) {
277
            throw new \InvalidArgumentException($msg);
278
        }
279
        $this->rowType[] = $property;
280
        return $this;
281
    }
282
283
    /**
284
     * isset rowType
285
     *
286
     * @param scalar $index
287
     * @return boolean
288
     */
289
    public function issetRowType($index)
290
    {
291
        return isset($this->rowType[$index]);
292
    }
293
294
    /**
295
     * unset rowType
296
     *
297
     * @param scalar $index
298
     * @return void
299
     */
300
    public function unsetRowType($index)
301
    {
302
        unset($this->rowType[$index]);
303
    }
304
305
    /**
306
     * Gets as rowType
307
     *
308
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[]
309
     */
310
    public function getRowType()
311
    {
312
        return $this->rowType;
313
    }
314
315
    /**
316
     * Sets a new rowType
317
     *
318
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
319
     * @return self
320
     */
321
    public function setRowType(array $rowType)
322
    {
323
        if (!$this->isValidArrayOK(
324
            $rowType,
325
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType',
326
            $msg
327
        )) {
328
            throw new \InvalidArgumentException($msg);
329
        }
330
        $this->rowType = $rowType;
331
        return $this;
332
    }
333
334
    public function isOK(&$msg = null)
335
    {
336
        if (null != $this->type && !$this->isTWrappedFunctionTypeValid($this->type)) {
337
            $msg = "Type must be a valid TWrappedFunctionType";
338
            return false;
339
        }
340
        if (!$this->isValidArrayOK($this->operand, '\AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType', $msg, 1)) {
341
            return false;
342
        }
343
        if (!$this->isTFacetAttributesTraitValid($msg)) {
344
            return false;
345
        }
346
        if (!$this->isValidArrayOK(
347
            $this->collectionType,
348
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType',
349
            $msg
350
        )) {
351
            return false;
352
        }
353
        if (!$this->isValidArrayOK(
354
            $this->referenceType,
355
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType',
356
            $msg
357
        )) {
358
            return false;
359
        }
360
        if (!$this->isValidArrayOK(
361
            $this->rowType,
362
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType',
363
            $msg
364
        )) {
365
            return false;
366
        }
367
368
        $count = (0 < count($this->collectionType) ? 1 : 0)
369
                 + (0 < count($this->referenceType) ? 1 : 0)
370
                 + (0 < count($this->rowType) ? 1 : 0);
371
        if (1 < $count) {
372
            $msg = "At most one of collection type, reference type and row type can be nonempty";
373
            return false;
374
        }
375
        return true;
376
    }
377
}
378