Passed
Push — master ( bc609e...49bb39 )
by Alex
03:56
created

TComplexPropertyType::unsetScalarProperty()   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\mapping\cs;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV4\edm\IsOKTraits\TSimpleIdentifierTrait;
7
8
/**
9
 * Class representing TComplexPropertyType
10
 *
11
 *
12
 * XSD Type: TComplexProperty
13
 */
14
class TComplexPropertyType extends IsOK
15
{
16
    use TSimpleIdentifierTrait;
17
    /**
18
     * @property string $name
19
     */
20
    private $name = null;
21
22
    /**
23
     * @property string $typeName
24
     */
25
    private $typeName = null;
26
27
    /**
28
     * @property boolean $isPartial
29
     */
30
    private $isPartial = null;
31
32
    /**
33
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType[] $scalarProperty
34
     */
35
    private $scalarProperty = [];
36
37
    /**
38
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType[] $complexProperty
39
     */
40
    private $complexProperty = [];
41
42
    /**
43
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexTypeMappingType[] $complexTypeMapping
44
     */
45
    private $complexTypeMapping = [];
46
47
    /**
48
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] $condition
49
     */
50
    private $condition = [];
51
52
    /**
53
     * Gets as name
54
     *
55
     * @return string
56
     */
57
    public function getName()
58
    {
59
        return $this->name;
60
    }
61
62
    /**
63
     * Sets a new name
64
     *
65
     * @param string $name
66
     * @return self
67
     */
68
    public function setName($name)
69
    {
70
        $this->name = $name;
71
        return $this;
72
    }
73
74
    /**
75
     * Gets as typeName
76
     *
77
     * @return string
78
     */
79
    public function getTypeName()
80
    {
81
        return $this->typeName;
82
    }
83
84
    /**
85
     * Sets a new typeName
86
     *
87
     * @param string $typeName
88
     * @return self
89
     */
90
    public function setTypeName($typeName)
91
    {
92
        $this->typeName = $typeName;
93
        return $this;
94
    }
95
96
    /**
97
     * Gets as isPartial
98
     *
99
     * @return boolean
100
     */
101
    public function getIsPartial()
102
    {
103
        return $this->isPartial;
104
    }
105
106
    /**
107
     * Sets a new isPartial
108
     *
109
     * @param boolean $isPartial
110
     * @return self
111
     */
112
    public function setIsPartial($isPartial)
113
    {
114
        $this->isPartial = $isPartial;
115
        return $this;
116
    }
117
118
    /**
119
     * Adds as scalarProperty
120
     *
121
     * @return self
122
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType $scalarProperty
123
     */
124
    public function addToScalarProperty(TScalarPropertyType $scalarProperty)
125
    {
126
        $this->scalarProperty[] = $scalarProperty;
127
        return $this;
128
    }
129
130
    /**
131
     * isset scalarProperty
132
     *
133
     * @param scalar $index
134
     * @return boolean
135
     */
136
    public function issetScalarProperty($index)
137
    {
138
        return isset($this->scalarProperty[$index]);
139
    }
140
141
    /**
142
     * unset scalarProperty
143
     *
144
     * @param scalar $index
145
     * @return void
146
     */
147
    public function unsetScalarProperty($index)
148
    {
149
        unset($this->scalarProperty[$index]);
150
    }
151
152
    /**
153
     * Gets as scalarProperty
154
     *
155
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType[]
156
     */
157
    public function getScalarProperty()
158
    {
159
        return $this->scalarProperty;
160
    }
161
162
    /**
163
     * Sets a new scalarProperty
164
     *
165
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType[] $scalarProperty
166
     * @return self
167
     */
168
    public function setScalarProperty(array $scalarProperty)
169
    {
170
        $this->scalarProperty = $scalarProperty;
171
        return $this;
172
    }
173
174
    /**
175
     * Adds as complexProperty
176
     *
177
     * @return self
178
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType $complexProperty
179
     */
180
    public function addToComplexProperty(TComplexPropertyType $complexProperty)
181
    {
182
        $this->complexProperty[] = $complexProperty;
183
        return $this;
184
    }
185
186
    /**
187
     * isset complexProperty
188
     *
189
     * @param scalar $index
190
     * @return boolean
191
     */
192
    public function issetComplexProperty($index)
193
    {
194
        return isset($this->complexProperty[$index]);
195
    }
196
197
    /**
198
     * unset complexProperty
199
     *
200
     * @param scalar $index
201
     * @return void
202
     */
203
    public function unsetComplexProperty($index)
204
    {
205
        unset($this->complexProperty[$index]);
206
    }
207
208
    /**
209
     * Gets as complexProperty
210
     *
211
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType[]
212
     */
213
    public function getComplexProperty()
214
    {
215
        return $this->complexProperty;
216
    }
217
218
    /**
219
     * Sets a new complexProperty
220
     *
221
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType[] $complexProperty
222
     * @return self
223
     */
224
    public function setComplexProperty(array $complexProperty)
225
    {
226
        $this->complexProperty = $complexProperty;
227
        return $this;
228
    }
229
230
    /**
231
     * Adds as complexTypeMapping
232
     *
233
     * @return self
234
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexTypeMappingType $complexTypeMapping
235
     */
236
    public function addToComplexTypeMapping(TComplexTypeMappingType $complexTypeMapping)
237
    {
238
        $this->complexTypeMapping[] = $complexTypeMapping;
239
        return $this;
240
    }
241
242
    /**
243
     * isset complexTypeMapping
244
     *
245
     * @param scalar $index
246
     * @return boolean
247
     */
248
    public function issetComplexTypeMapping($index)
249
    {
250
        return isset($this->complexTypeMapping[$index]);
251
    }
252
253
    /**
254
     * unset complexTypeMapping
255
     *
256
     * @param scalar $index
257
     * @return void
258
     */
259
    public function unsetComplexTypeMapping($index)
260
    {
261
        unset($this->complexTypeMapping[$index]);
262
    }
263
264
    /**
265
     * Gets as complexTypeMapping
266
     *
267
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexTypeMappingType[]
268
     */
269
    public function getComplexTypeMapping()
270
    {
271
        return $this->complexTypeMapping;
272
    }
273
274
    /**
275
     * Sets a new complexTypeMapping
276
     *
277
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexTypeMappingType[] $complexTypeMapping
278
     * @return self
279
     */
280
    public function setComplexTypeMapping(array $complexTypeMapping)
281
    {
282
        $this->complexTypeMapping = $complexTypeMapping;
283
        return $this;
284
    }
285
286
    /**
287
     * Adds as condition
288
     *
289
     * @return self
290
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition
291
     */
292
    public function addToCondition(TConditionType $condition)
293
    {
294
        $this->condition[] = $condition;
295
        return $this;
296
    }
297
298
    /**
299
     * isset condition
300
     *
301
     * @param scalar $index
302
     * @return boolean
303
     */
304
    public function issetCondition($index)
305
    {
306
        return isset($this->condition[$index]);
307
    }
308
309
    /**
310
     * unset condition
311
     *
312
     * @param scalar $index
313
     * @return void
314
     */
315
    public function unsetCondition($index)
316
    {
317
        unset($this->condition[$index]);
318
    }
319
320
    /**
321
     * Gets as condition
322
     *
323
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[]
324
     */
325
    public function getCondition()
326
    {
327
        return $this->condition;
328
    }
329
330
    /**
331
     * Sets a new condition
332
     *
333
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] $condition
334
     * @return self
335
     */
336
    public function setCondition(array $condition)
337
    {
338
        $this->condition = $condition;
339
        return $this;
340
    }
341
342
    public function isOK(&$msg = null)
343
    {
344
        if (!$this->isStringNotNullOrEmpty($this->name)) {
345
            $msg = 'Name cannot be null or empty';
346
            return false;
347
        }
348 View Code Duplication
        if (null != $this->typeName && !$this->isStringNotNullOrEmpty($this->typeName)) {
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...
349
            $msg = 'Type name cannot be empty';
350
            return false;
351
        }
352
        if (!$this->isTSimpleIdentifierValid($this->name)) {
353
            $msg = 'Name must be a valid TSimpleIdentifier';
354
            return false;
355
        }
356
        $count = count($this->scalarProperty) + count($this->complexProperty) + count($this->condition)
357
                 + count($this->complexTypeMapping);
358
        if (1 > $count) {
359
            $msg = "Cannot have all arrays empty";
360
            return false;
361
        }
362
363
        if (!$this->isValidArray(
364
            $this->scalarProperty,
365
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType'
366
        )) {
367
            $msg = "Scalar property array not a valid array";
368
            return false;
369
        }
370
        if (!$this->isChildArrayOK($this->scalarProperty, $msg)) {
371
            return false;
372
        }
373
        if (!$this->isValidArray(
374
            $this->complexProperty,
375
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType'
376
        )) {
377
            $msg = "Complex property array not a valid array";
378
            return false;
379
        }
380
        if (!$this->isChildArrayOK($this->complexProperty, $msg)) {
381
            return false;
382
        }
383
        if (!$this->isValidArray(
384
            $this->condition,
385
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType'
386
        )) {
387
            $msg = "Condition array not a valid array";
388
            return false;
389
        }
390
        if (!$this->isChildArrayOK($this->condition, $msg)) {
391
            return false;
392
        }
393
        if (!$this->isValidArray(
394
            $this->complexTypeMapping,
395
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexTypeMappingType'
396
        )) {
397
            $msg = "Complex type mapping array not a valid array";
398
            return false;
399
        }
400
        if (!$this->isChildArrayOK($this->complexTypeMapping, $msg)) {
401
            return false;
402
        }
403
        return true;
404
    }
405
}
406