Passed
Push — master ( 143625...0aa694 )
by Alex
03:46
created

TTypeAssertExpressionType::isOK()   C

Complexity

Conditions 12
Paths 22

Size

Total Lines 43
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 5.1612
c 0
b 0
f 0
cc 12
eloc 30
nc 22
nop 1

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\TWrappedFunctionReturnTypeTrait;
9
10
/**
11
 * Class representing TTypeAssertExpressionType
12
 *
13
 *
14
 * XSD Type: TTypeAssertExpression
15
 */
16
class TTypeAssertExpressionType extends IsOK
17
{
18
    use IsOKToolboxTrait, TFacetAttributesTrait, TWrappedFunctionReturnTypeTrait;
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
        $this->type = $type;
63
        return $this;
64
    }
65
66
    /**
67
     * Adds as operand
68
     *
69
     * @return self
70
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType $operand
71
     */
72
    public function addToOperand(TOperandType $operand)
73
    {
74
        $this->operand[] = $operand;
75
        return $this;
76
    }
77
78
    /**
79
     * isset operand
80
     *
81
     * @param scalar $index
82
     * @return boolean
83
     */
84
    public function issetOperand($index)
85
    {
86
        return isset($this->operand[$index]);
87
    }
88
89
    /**
90
     * unset operand
91
     *
92
     * @param scalar $index
93
     * @return void
94
     */
95
    public function unsetOperand($index)
96
    {
97
        unset($this->operand[$index]);
98
    }
99
100
    /**
101
     * Gets as operand
102
     *
103
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType[]
104
     */
105
    public function getOperand()
106
    {
107
        return $this->operand;
108
    }
109
110
    /**
111
     * Sets a new operand
112
     *
113
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType[] $operand
114
     * @return self
115
     */
116
    public function setOperand(array $operand)
117
    {
118
        $this->operand = $operand;
119
        return $this;
120
    }
121
122
    /**
123
     * Adds as collectionType
124
     *
125
     * @return self
126
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType $collectionType
127
     */
128
    public function addToCollectionType(TCollectionTypeType $collectionType)
129
    {
130
        $this->collectionType[] = $collectionType;
131
        return $this;
132
    }
133
134
    /**
135
     * isset collectionType
136
     *
137
     * @param scalar $index
138
     * @return boolean
139
     */
140
    public function issetCollectionType($index)
141
    {
142
        return isset($this->collectionType[$index]);
143
    }
144
145
    /**
146
     * unset collectionType
147
     *
148
     * @param scalar $index
149
     * @return void
150
     */
151
    public function unsetCollectionType($index)
152
    {
153
        unset($this->collectionType[$index]);
154
    }
155
156
    /**
157
     * Gets as collectionType
158
     *
159
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[]
160
     */
161
    public function getCollectionType()
162
    {
163
        return $this->collectionType;
164
    }
165
166
    /**
167
     * Sets a new collectionType
168
     *
169
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType[] $collectionType
170
     * @return self
171
     */
172
    public function setCollectionType(array $collectionType)
173
    {
174
        $this->collectionType = $collectionType;
175
        return $this;
176
    }
177
178
    /**
179
     * Adds as referenceType
180
     *
181
     * @return self
182
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType $referenceType
183
     */
184
    public function addToReferenceType(TReferenceTypeType $referenceType)
185
    {
186
        $this->referenceType[] = $referenceType;
187
        return $this;
188
    }
189
190
    /**
191
     * isset referenceType
192
     *
193
     * @param scalar $index
194
     * @return boolean
195
     */
196
    public function issetReferenceType($index)
197
    {
198
        return isset($this->referenceType[$index]);
199
    }
200
201
    /**
202
     * unset referenceType
203
     *
204
     * @param scalar $index
205
     * @return void
206
     */
207
    public function unsetReferenceType($index)
208
    {
209
        unset($this->referenceType[$index]);
210
    }
211
212
    /**
213
     * Gets as referenceType
214
     *
215
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[]
216
     */
217
    public function getReferenceType()
218
    {
219
        return $this->referenceType;
220
    }
221
222
    /**
223
     * Sets a new referenceType
224
     *
225
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType[] $referenceType
226
     * @return self
227
     */
228
    public function setReferenceType(array $referenceType)
229
    {
230
        $this->referenceType = $referenceType;
231
        return $this;
232
    }
233
234
    /**
235
     * Adds as property
236
     *
237
     * @return self
238
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType $property
239
     */
240
    public function addToRowType(TPropertyType $property)
241
    {
242
        $this->rowType[] = $property;
243
        return $this;
244
    }
245
246
    /**
247
     * isset rowType
248
     *
249
     * @param scalar $index
250
     * @return boolean
251
     */
252
    public function issetRowType($index)
253
    {
254
        return isset($this->rowType[$index]);
255
    }
256
257
    /**
258
     * unset rowType
259
     *
260
     * @param scalar $index
261
     * @return void
262
     */
263
    public function unsetRowType($index)
264
    {
265
        unset($this->rowType[$index]);
266
    }
267
268
    /**
269
     * Gets as rowType
270
     *
271
     * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[]
272
     */
273
    public function getRowType()
274
    {
275
        return $this->rowType;
276
    }
277
278
    /**
279
     * Sets a new rowType
280
     *
281
     * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType[] $rowType
282
     * @return self
283
     */
284
    public function setRowType(array $rowType)
285
    {
286
        $this->rowType = $rowType;
287
        return $this;
288
    }
289
290
    public function isOK(&$msg = null)
291
    {
292
        if (null != $this->type && !$this->isTWrappedFunctionTypeValid($this->type)) {
293
            $msg = "Type must be a valid TWrappedFunctionType";
294
            return false;
295
        }
296
        if (!$this->isValidArrayOK($this->operand, '\AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType', $msg, 1)) {
297
            return false;
298
        }
299
        if (!$this->isTFacetAttributesTraitValid($msg)) {
300
            return false;
301
        }
302
        if (!$this->isValidArrayOK(
303
            $this->collectionType,
304
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionTypeType',
305
            $msg
306
        )) {
307
            return false;
308
        }
309
        if (!$this->isValidArrayOK(
310
            $this->referenceType,
311
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TReferenceTypeType',
312
            $msg
313
        )) {
314
            return false;
315
        }
316
        if (!$this->isValidArrayOK(
317
            $this->rowType,
318
            '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyType',
319
            $msg
320
        )) {
321
            return false;
322
        }
323
324
        $count = (0 < count($this->collectionType) ? 1 : 0)
325
                 + (0 < count($this->referenceType) ? 1 : 0)
326
                 + (0 < count($this->rowType) ? 1 : 0);
327
        if (1 < $count) {
328
            $msg = "At most one of collection type, reference type and row type can be nonempty";
329
            return false;
330
        }
331
        return true;
332
    }
333
}
334