Passed
Push — master ( 33a99c...5afa10 )
by Alex
04:00
created

TComplexTypeMappingType::addToScalarProperty()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 6
nc 2
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 (!$this->isValidArrayOK(
150
            $scalarProperty,
151
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType',
152
            $msg
153
        )) {
154
            throw new \InvalidArgumentException($msg);
155
        }
156
        $this->scalarProperty = $scalarProperty;
157
        return $this;
158
    }
159
160
    /**
161
     * Adds as complexProperty
162
     *
163
     * @return self
164
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType $complexProperty
165
     */
166 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...
167
    {
168
        $msg = null;
169
        if (!$complexProperty->isOK($msg)) {
170
            throw new \InvalidArgumentException($msg);
171
        }
172
        $this->complexProperty[] = $complexProperty;
173
        return $this;
174
    }
175
176
    /**
177
     * isset complexProperty
178
     *
179
     * @param scalar $index
180
     * @return boolean
181
     */
182
    public function issetComplexProperty($index)
183
    {
184
        return isset($this->complexProperty[$index]);
185
    }
186
187
    /**
188
     * unset complexProperty
189
     *
190
     * @param scalar $index
191
     * @return void
192
     */
193
    public function unsetComplexProperty($index)
194
    {
195
        unset($this->complexProperty[$index]);
196
    }
197
198
    /**
199
     * Gets as complexProperty
200
     *
201
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType[]
202
     */
203
    public function getComplexProperty()
204
    {
205
        return $this->complexProperty;
206
    }
207
208
    /**
209
     * Sets a new complexProperty
210
     *
211
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType[] $complexProperty
212
     * @return self
213
     */
214 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...
215
    {
216
        $msg = null;
217
        if (!$this->isValidArrayOK(
218
            $complexProperty,
219
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType',
220
            $msg
221
        )) {
222
            throw new \InvalidArgumentException($msg);
223
        }
224
        $this->complexProperty = $complexProperty;
225
        return $this;
226
    }
227
228
    /**
229
     * Adds as condition
230
     *
231
     * @return self
232
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType $condition
233
     */
234 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...
235
    {
236
        $msg = null;
237
        if (!$condition->isOK($msg)) {
238
            throw new \InvalidArgumentException($msg);
239
        }
240
        $this->condition[] = $condition;
241
        return $this;
242
    }
243
244
    /**
245
     * isset condition
246
     *
247
     * @param scalar $index
248
     * @return boolean
249
     */
250
    public function issetCondition($index)
251
    {
252
        return isset($this->condition[$index]);
253
    }
254
255
    /**
256
     * unset condition
257
     *
258
     * @param scalar $index
259
     * @return void
260
     */
261
    public function unsetCondition($index)
262
    {
263
        unset($this->condition[$index]);
264
    }
265
266
    /**
267
     * Gets as condition
268
     *
269
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[]
270
     */
271
    public function getCondition()
272
    {
273
        return $this->condition;
274
    }
275
276
    /**
277
     * Sets a new condition
278
     *
279
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType[] $condition
280
     * @return self
281
     */
282 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...
283
    {
284
        $msg = null;
285
        if (!$this->isValidArrayOK(
286
            $condition,
287
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType',
288
            $msg
289
        )) {
290
            throw new \InvalidArgumentException($msg);
291
        }
292
        $this->condition = $condition;
293
        return $this;
294
    }
295
296
    public function isOK(&$msg = null)
297
    {
298 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...
299
            if (!$this->isStringNotNullOrEmpty($this->typeName)) {
300
                $msg = 'Type name cannot be empty';
301
                return false;
302
            }
303
        }
304
        $count = count($this->scalarProperty) + count($this->complexProperty) + count($this->condition);
305
        if (1 > $count) {
306
            $msg = "Cannot have all arrays empty";
307
            return false;
308
        }
309
310
        if (!$this->isValidArray(
311
            $this->scalarProperty,
312
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TScalarPropertyType'
313
        )) {
314
            $msg = "Scalar property array not a valid array";
315
            return false;
316
        }
317
        if (!$this->isChildArrayOK($this->scalarProperty, $msg)) {
318
            return false;
319
        }
320
        if (!$this->isValidArray(
321
            $this->complexProperty,
322
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TComplexPropertyType'
323
        )) {
324
            $msg = "Complex property array not a valid array";
325
            return false;
326
        }
327
        if (!$this->isChildArrayOK($this->complexProperty, $msg)) {
328
            return false;
329
        }
330
        if (!$this->isValidArray(
331
            $this->condition,
332
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TConditionType'
333
        )) {
334
            $msg = "Condition array not a valid array";
335
            return false;
336
        }
337
        if (!$this->isChildArrayOK($this->condition, $msg)) {
338
            return false;
339
        }
340
        return true;
341
    }
342
}
343