Completed
Push — master ( 941487...1b7170 )
by Alex
12:44 queued 07:23
created

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