Completed
Push — master ( 1b7170...9fa28d )
by Alex
05:38
created

TEntityContainerMappingType::isOK()   C

Complexity

Conditions 10
Paths 10

Size

Total Lines 49
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 5.5471
c 0
b 0
f 0
cc 10
eloc 32
nc 10
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\mapping\cs;
4
5
use AlgoWeb\ODataMetadata\IsOK;
6
use AlgoWeb\ODataMetadata\MetadataV4\edm\IsOKTraits\TSimpleIdentifierTrait;
7
8
/**
9
 * Class representing TEntityContainerMappingType
10
 *
11
 * Type for EntityContainerMapping element
12
 *
13
 * XSD Type: TEntityContainerMapping
14
 */
15
class TEntityContainerMappingType extends IsOK
16
{
17
    use TSimpleIdentifierTrait;
18
    /**
19
     * @property string $cdmEntityContainer
20
     */
21
    private $cdmEntityContainer = null;
22
23
    /**
24
     * @property string $storageEntityContainer
25
     */
26
    private $storageEntityContainer = null;
27
28
    /**
29
     * @property boolean $generateUpdateViews
30
     */
31
    private $generateUpdateViews = null;
32
33
    /**
34
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType[] $entitySetMapping
35
     */
36
    private $entitySetMapping = [];
37
38
    /**
39
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType[]
40
     * $associationSetMapping
41
     */
42
    private $associationSetMapping = [];
43
44
    /**
45
     * @property \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType[]
46
     * $functionImportMapping
47
     */
48
    private $functionImportMapping = [];
49
50
    /**
51
     * Gets as cdmEntityContainer
52
     *
53
     * @return string
54
     */
55
    public function getCdmEntityContainer()
56
    {
57
        return $this->cdmEntityContainer;
58
    }
59
60
    /**
61
     * Sets a new cdmEntityContainer
62
     *
63
     * @param  string $cdmEntityContainer
64
     * @return self
65
     */
66
    public function setCdmEntityContainer($cdmEntityContainer)
67
    {
68
        if (!$this->isStringNotNullOrEmpty($cdmEntityContainer)) {
69
            $msg = 'CDM entity container cannot be null or empty';
70
            throw new \InvalidArgumentException($msg);
71
        }
72
        if (!$this->isTSimpleIdentifierValid($cdmEntityContainer)) {
73
            $msg = 'CDM entity container must be a valid TSimpleIdentifier';
74
            throw new \InvalidArgumentException($msg);
75
        }
76
        $this->cdmEntityContainer = $cdmEntityContainer;
77
        return $this;
78
    }
79
80
    /**
81
     * Gets as storageEntityContainer
82
     *
83
     * @return string
84
     */
85
    public function getStorageEntityContainer()
86
    {
87
        return $this->storageEntityContainer;
88
    }
89
90
    /**
91
     * Sets a new storageEntityContainer
92
     *
93
     * @param  string $storageEntityContainer
94
     * @return self
95
     */
96
    public function setStorageEntityContainer($storageEntityContainer)
97
    {
98
        if (!$this->isStringNotNullOrEmpty($storageEntityContainer)) {
99
            $msg = 'Storage entity container cannot be null or empty';
100
            throw new \InvalidArgumentException($msg);
101
        }
102
        $this->storageEntityContainer = $storageEntityContainer;
103
        return $this;
104
    }
105
106
    /**
107
     * Gets as generateUpdateViews
108
     *
109
     * @return boolean
110
     */
111
    public function getGenerateUpdateViews()
112
    {
113
        return $this->generateUpdateViews;
114
    }
115
116
    /**
117
     * Sets a new generateUpdateViews
118
     *
119
     * @param  boolean $generateUpdateViews
120
     * @return self
121
     */
122
    public function setGenerateUpdateViews($generateUpdateViews)
123
    {
124
        $this->generateUpdateViews = $generateUpdateViews;
125
        return $this;
126
    }
127
128
    /**
129
     * Adds as entitySetMapping
130
     *
131
     * @return self
132
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType $entitySetMapping
133
     */
134 View Code Duplication
    public function addToEntitySetMapping(TEntitySetMappingType $entitySetMapping)
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...
135
    {
136
        $msg = null;
137
        if (!$entitySetMapping->isOK($msg)) {
138
            throw new \InvalidArgumentException($msg);
139
        }
140
        $this->entitySetMapping[] = $entitySetMapping;
141
        return $this;
142
    }
143
144
    /**
145
     * isset entitySetMapping
146
     *
147
     * @param  scalar $index
148
     * @return boolean
149
     */
150
    public function issetEntitySetMapping($index)
151
    {
152
        return isset($this->entitySetMapping[$index]);
153
    }
154
155
    /**
156
     * unset entitySetMapping
157
     *
158
     * @param  scalar $index
159
     * @return void
160
     */
161
    public function unsetEntitySetMapping($index)
162
    {
163
        unset($this->entitySetMapping[$index]);
164
    }
165
166
    /**
167
     * Gets as entitySetMapping
168
     *
169
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType[]
170
     */
171
    public function getEntitySetMapping()
172
    {
173
        return $this->entitySetMapping;
174
    }
175
176
    /**
177
     * Sets a new entitySetMapping
178
     *
179
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType[] $entitySetMapping
180
     * @return self
181
     */
182 View Code Duplication
    public function setEntitySetMapping(array $entitySetMapping)
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...
183
    {
184
        $msg = null;
185
        if (!$this->isValidArrayOK(
186
            $entitySetMapping,
187
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType',
188
            $msg
189
        )
190
        ) {
191
            throw new \InvalidArgumentException($msg);
192
        }
193
        $this->entitySetMapping = $entitySetMapping;
194
        return $this;
195
    }
196
197
    /**
198
     * Adds as associationSetMapping
199
     *
200
     * @return self
201
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType $associationSetMapping
202
     */
203 View Code Duplication
    public function addToAssociationSetMapping(TAssociationSetMappingType $associationSetMapping)
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...
204
    {
205
        $msg = null;
206
        if (!$associationSetMapping->isOK($msg)) {
207
            throw new \InvalidArgumentException($msg);
208
        }
209
        $this->associationSetMapping[] = $associationSetMapping;
210
        return $this;
211
    }
212
213
    /**
214
     * isset associationSetMapping
215
     *
216
     * @param  scalar $index
217
     * @return boolean
218
     */
219
    public function issetAssociationSetMapping($index)
220
    {
221
        return isset($this->associationSetMapping[$index]);
222
    }
223
224
    /**
225
     * unset associationSetMapping
226
     *
227
     * @param  scalar $index
228
     * @return void
229
     */
230
    public function unsetAssociationSetMapping($index)
231
    {
232
        unset($this->associationSetMapping[$index]);
233
    }
234
235
    /**
236
     * Gets as associationSetMapping
237
     *
238
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType[]
239
     */
240
    public function getAssociationSetMapping()
241
    {
242
        return $this->associationSetMapping;
243
    }
244
245
    /**
246
     * Sets a new associationSetMapping
247
     *
248
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType[]
249
     * $associationSetMapping
250
     * @return self
251
     */
252 View Code Duplication
    public function setAssociationSetMapping(array $associationSetMapping)
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...
253
    {
254
        $msg = null;
255
        if (!$this->isValidArrayOK(
256
            $associationSetMapping,
257
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType',
258
            $msg
259
        )
260
        ) {
261
            throw new \InvalidArgumentException($msg);
262
        }
263
        $this->associationSetMapping = $associationSetMapping;
264
        return $this;
265
    }
266
267
    /**
268
     * Adds as functionImportMapping
269
     *
270
     * @return self
271
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType $functionImportMapping
272
     */
273 View Code Duplication
    public function addToFunctionImportMapping(TFunctionImportMappingType $functionImportMapping)
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...
274
    {
275
        $msg = null;
276
        if (!$functionImportMapping->isOK($msg)) {
277
            throw new \InvalidArgumentException($msg);
278
        }
279
        $this->functionImportMapping[] = $functionImportMapping;
280
        return $this;
281
    }
282
283
    /**
284
     * isset functionImportMapping
285
     *
286
     * @param  scalar $index
287
     * @return boolean
288
     */
289
    public function issetFunctionImportMapping($index)
290
    {
291
        return isset($this->functionImportMapping[$index]);
292
    }
293
294
    /**
295
     * unset functionImportMapping
296
     *
297
     * @param  scalar $index
298
     * @return void
299
     */
300
    public function unsetFunctionImportMapping($index)
301
    {
302
        unset($this->functionImportMapping[$index]);
303
    }
304
305
    /**
306
     * Gets as functionImportMapping
307
     *
308
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType[]
309
     */
310
    public function getFunctionImportMapping()
311
    {
312
        return $this->functionImportMapping;
313
    }
314
315
    /**
316
     * Sets a new functionImportMapping
317
     *
318
     * @param  \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType[]
319
     * $functionImportMapping
320
     * @return self
321
     */
322 View Code Duplication
    public function setFunctionImportMapping(array $functionImportMapping)
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...
323
    {
324
        $msg = null;
325
        if (!$this->isValidArrayOK(
326
            $functionImportMapping,
327
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType',
328
            $msg
329
        )
330
        ) {
331
            throw new \InvalidArgumentException($msg);
332
        }
333
        $this->functionImportMapping = $functionImportMapping;
334
        return $this;
335
    }
336
337
    public function isOK(&$msg = null)
338
    {
339
        if (!$this->isStringNotNullOrEmpty($this->cdmEntityContainer)) {
340
            $msg = 'CDM entity container cannot be null or empty';
341
            return false;
342
        }
343
        if (!$this->isStringNotNullOrEmpty($this->storageEntityContainer)) {
344
            $msg = 'Storage entity container cannot be null or empty';
345
            return false;
346
        }
347
        if (!$this->isTSimpleIdentifierValid($this->cdmEntityContainer)) {
348
            $msg = 'CDM entity container must be a valid TSimpleIdentifier';
349
            return false;
350
        }
351
        if (!$this->isValidArray(
352
            $this->entitySetMapping,
353
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType'
354
        )
355
        ) {
356
            $msg = "Entity set mapping array not a valid array";
357
            return false;
358
        }
359
        if (!$this->isChildArrayOK($this->entitySetMapping, $msg)) {
360
            return false;
361
        }
362
        if (!$this->isValidArray(
363
            $this->associationSetMapping,
364
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType'
365
        )
366
        ) {
367
            $msg = "Association set mapping array not a valid array";
368
            return false;
369
        }
370
        if (!$this->isChildArrayOK($this->associationSetMapping, $msg)) {
371
            return false;
372
        }
373
        if (!$this->isValidArray(
374
            $this->functionImportMapping,
375
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType'
376
        )
377
        ) {
378
            $msg = "Function import mapping array not a valid array";
379
            return false;
380
        }
381
        if (!$this->isChildArrayOK($this->functionImportMapping, $msg)) {
382
            return false;
383
        }
384
        return true;
385
    }
386
}
387