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

TComplexTypeMappingType::addToComplexProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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