Test Failed
Push — master ( c06ec5...9a90c3 )
by Alex
04:44
created

TEntityContainerMappingType   B

Complexity

Total Complexity 37

Size/Duplication

Total Lines 354
Duplicated Lines 18.64 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 37
lcom 1
cbo 5
dl 66
loc 354
rs 8.6
c 0
b 0
f 0

22 Methods

Rating   Name   Duplication   Size   Complexity  
A getCdmEntityContainer() 0 4 1
A setCdmEntityContainer() 0 5 1
A getStorageEntityContainer() 0 4 1
A setStorageEntityContainer() 0 5 1
A getGenerateUpdateViews() 0 4 1
A setGenerateUpdateViews() 0 5 1
A issetEntitySetMapping() 0 4 1
A unsetEntitySetMapping() 0 4 1
A getEntitySetMapping() 0 4 1
A addToEntitySetMapping() 9 9 2
A setEntitySetMapping() 13 13 2
A addToAssociationSetMapping() 9 9 2
A issetAssociationSetMapping() 0 4 1
A unsetAssociationSetMapping() 0 4 1
A getAssociationSetMapping() 0 4 1
A setAssociationSetMapping() 13 13 2
A addToFunctionImportMapping() 9 9 2
A issetFunctionImportMapping() 0 4 1
A unsetFunctionImportMapping() 0 4 1
A getFunctionImportMapping() 0 4 1
A setFunctionImportMapping() 13 13 2
D isOK() 0 46 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
        $this->cdmEntityContainer = $cdmEntityContainer;
69
        return $this;
70
    }
71
72
    /**
73
     * Gets as storageEntityContainer
74
     *
75
     * @return string
76
     */
77
    public function getStorageEntityContainer()
78
    {
79
        return $this->storageEntityContainer;
80
    }
81
82
    /**
83
     * Sets a new storageEntityContainer
84
     *
85
     * @param string $storageEntityContainer
86
     * @return self
87
     */
88
    public function setStorageEntityContainer($storageEntityContainer)
89
    {
90
        $this->storageEntityContainer = $storageEntityContainer;
91
        return $this;
92
    }
93
94
    /**
95
     * Gets as generateUpdateViews
96
     *
97
     * @return boolean
98
     */
99
    public function getGenerateUpdateViews()
100
    {
101
        return $this->generateUpdateViews;
102
    }
103
104
    /**
105
     * Sets a new generateUpdateViews
106
     *
107
     * @param boolean $generateUpdateViews
108
     * @return self
109
     */
110
    public function setGenerateUpdateViews($generateUpdateViews)
111
    {
112
        $this->generateUpdateViews = $generateUpdateViews;
113
        return $this;
114
    }
115
116
    /**
117
     * Adds as entitySetMapping
118
     *
119
     * @return self
120
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType $entitySetMapping
121
     */
122 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...
123
    {
124
        $msg = null;
125
        if (!$entitySetMapping->isOK($msg)) {
126
            throw new \InvalidArgumentException($msg);
127
        }
128
        $this->entitySetMapping[] = $entitySetMapping;
129
        return $this;
130
    }
131
132
    /**
133
     * isset entitySetMapping
134
     *
135
     * @param scalar $index
136
     * @return boolean
137
     */
138
    public function issetEntitySetMapping($index)
139
    {
140
        return isset($this->entitySetMapping[$index]);
141
    }
142
143
    /**
144
     * unset entitySetMapping
145
     *
146
     * @param scalar $index
147
     * @return void
148
     */
149
    public function unsetEntitySetMapping($index)
150
    {
151
        unset($this->entitySetMapping[$index]);
152
    }
153
154
    /**
155
     * Gets as entitySetMapping
156
     *
157
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType[]
158
     */
159
    public function getEntitySetMapping()
160
    {
161
        return $this->entitySetMapping;
162
    }
163
164
    /**
165
     * Sets a new entitySetMapping
166
     *
167
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType[] $entitySetMapping
168
     * @return self
169
     */
170 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...
171
    {
172
        $msg = null;
173
        if (!$this->isValidArrayOK(
174
            $entitySetMapping,
175
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType',
176
            $msg
177
        )) {
178
            throw new \InvalidArgumentException($msg);
179
        }
180
        $this->entitySetMapping = $entitySetMapping;
181
        return $this;
182
    }
183
184
    /**
185
     * Adds as associationSetMapping
186
     *
187
     * @return self
188
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType $associationSetMapping
189
     */
190 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...
191
    {
192
        $msg = null;
193
        if (!$associationSetMapping->isOK($msg)) {
194
            throw new \InvalidArgumentException($msg);
195
        }
196
        $this->associationSetMapping[] = $associationSetMapping;
197
        return $this;
198
    }
199
200
    /**
201
     * isset associationSetMapping
202
     *
203
     * @param scalar $index
204
     * @return boolean
205
     */
206
    public function issetAssociationSetMapping($index)
207
    {
208
        return isset($this->associationSetMapping[$index]);
209
    }
210
211
    /**
212
     * unset associationSetMapping
213
     *
214
     * @param scalar $index
215
     * @return void
216
     */
217
    public function unsetAssociationSetMapping($index)
218
    {
219
        unset($this->associationSetMapping[$index]);
220
    }
221
222
    /**
223
     * Gets as associationSetMapping
224
     *
225
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType[]
226
     */
227
    public function getAssociationSetMapping()
228
    {
229
        return $this->associationSetMapping;
230
    }
231
232
    /**
233
     * Sets a new associationSetMapping
234
     *
235
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType[]
236
     * $associationSetMapping
237
     * @return self
238
     */
239 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...
240
    {
241
        $msg = null;
242
        if (!$this->isValidArrayOK(
243
            $associationSetMapping,
244
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType',
245
            $msg
246
        )) {
247
            throw new \InvalidArgumentException($msg);
248
        }
249
        $this->associationSetMapping = $associationSetMapping;
250
        return $this;
251
    }
252
253
    /**
254
     * Adds as functionImportMapping
255
     *
256
     * @return self
257
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType $functionImportMapping
258
     */
259 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...
260
    {
261
        $msg = null;
262
        if (!$functionImportMapping->isOK($msg)) {
263
            throw new \InvalidArgumentException($msg);
264
        }
265
        $this->functionImportMapping[] = $functionImportMapping;
266
        return $this;
267
    }
268
269
    /**
270
     * isset functionImportMapping
271
     *
272
     * @param scalar $index
273
     * @return boolean
274
     */
275
    public function issetFunctionImportMapping($index)
276
    {
277
        return isset($this->functionImportMapping[$index]);
278
    }
279
280
    /**
281
     * unset functionImportMapping
282
     *
283
     * @param scalar $index
284
     * @return void
285
     */
286
    public function unsetFunctionImportMapping($index)
287
    {
288
        unset($this->functionImportMapping[$index]);
289
    }
290
291
    /**
292
     * Gets as functionImportMapping
293
     *
294
     * @return \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType[]
295
     */
296
    public function getFunctionImportMapping()
297
    {
298
        return $this->functionImportMapping;
299
    }
300
301
    /**
302
     * Sets a new functionImportMapping
303
     *
304
     * @param \AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType[]
305
     * $functionImportMapping
306
     * @return self
307
     */
308 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...
309
    {
310
        $msg = null;
311
        if (!$this->isValidArrayOK(
312
            $functionImportMapping,
313
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType',
314
            $msg
315
        )) {
316
            throw new \InvalidArgumentException($msg);
317
        }
318
        $this->functionImportMapping = $functionImportMapping;
319
        return $this;
320
    }
321
322
    public function isOK(&$msg = null)
323
    {
324
        if (!$this->isStringNotNullOrEmpty($this->cdmEntityContainer)) {
325
            $msg = 'CDM entity container cannot be null or empty';
326
            return false;
327
        }
328
        if (!$this->isStringNotNullOrEmpty($this->storageEntityContainer)) {
329
            $msg = 'Storage entity container cannot be null or empty';
330
            return false;
331
        }
332
        if (!$this->isTSimpleIdentifierValid($this->cdmEntityContainer)) {
333
            $msg = 'CDM entity container must be a valid TSimpleIdentifier';
334
            return false;
335
        }
336
        if (!$this->isValidArray(
337
            $this->entitySetMapping,
338
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TEntitySetMappingType'
339
        )) {
340
            $msg = "Entity set mapping array not a valid array";
341
            return false;
342
        }
343
        if (!$this->isChildArrayOK($this->entitySetMapping, $msg)) {
344
            return false;
345
        }
346
        if (!$this->isValidArray(
347
            $this->associationSetMapping,
348
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TAssociationSetMappingType'
349
        )) {
350
            $msg = "Association set mapping array not a valid array";
351
            return false;
352
        }
353
        if (!$this->isChildArrayOK($this->associationSetMapping, $msg)) {
354
            return false;
355
        }
356
        if (!$this->isValidArray(
357
            $this->functionImportMapping,
358
            '\AlgoWeb\ODataMetadata\MetadataV3\mapping\cs\TFunctionImportMappingType'
359
        )) {
360
            $msg = "Function import mapping array not a valid array";
361
            return false;
362
        }
363
        if (!$this->isChildArrayOK($this->functionImportMapping, $msg)) {
364
            return false;
365
        }
366
        return true;
367
    }
368
}
369