Passed
Push — master ( 583371...613693 )
by Alex
03:44
created

Schema   F

Complexity

Total Complexity 54

Size/Duplication

Total Lines 687
Duplicated Lines 0 %

Coupling/Cohesion

Components 10
Dependencies 0

Importance

Changes 0
Metric Value
wmc 54
lcom 10
cbo 0
dl 0
loc 687
rs 1.9061
c 0
b 0
f 0

54 Methods

Rating   Name   Duplication   Size   Complexity  
A getNamespace() 0 4 1
A setNamespace() 0 5 1
A getAlias() 0 4 1
A setAlias() 0 5 1
A addToComplexType() 0 5 1
A issetComplexType() 0 4 1
A unsetComplexType() 0 4 1
A getComplexType() 0 4 1
A setComplexType() 0 5 1
A addToEntityType() 0 5 1
A issetEntityType() 0 4 1
A unsetEntityType() 0 4 1
A getEntityType() 0 4 1
A setEntityType() 0 5 1
A addToTypeDefinition() 0 5 1
A issetTypeDefinition() 0 4 1
A unsetTypeDefinition() 0 4 1
A getTypeDefinition() 0 4 1
A setTypeDefinition() 0 5 1
A addToEnumType() 0 5 1
A issetEnumType() 0 4 1
A unsetEnumType() 0 4 1
A getEnumType() 0 4 1
A setEnumType() 0 5 1
A addToAction() 0 5 1
A issetAction() 0 4 1
A unsetAction() 0 4 1
A getAction() 0 4 1
A setAction() 0 5 1
A addToFunction() 0 5 1
A issetFunction() 0 4 1
A unsetFunction() 0 4 1
A getFunction() 0 4 1
A setFunction() 0 5 1
A addToTerm() 0 5 1
A issetTerm() 0 4 1
A unsetTerm() 0 4 1
A getTerm() 0 4 1
A setTerm() 0 5 1
A addToAnnotations() 0 5 1
A issetAnnotations() 0 4 1
A unsetAnnotations() 0 4 1
A getAnnotations() 0 4 1
A setAnnotations() 0 5 1
A addToEntityContainer() 0 5 1
A issetEntityContainer() 0 4 1
A unsetEntityContainer() 0 4 1
A getEntityContainer() 0 4 1
A setEntityContainer() 0 5 1
A addToAnnotation() 0 5 1
A issetAnnotation() 0 4 1
A unsetAnnotation() 0 4 1
A getAnnotation() 0 4 1
A setAnnotation() 0 5 1

How to fix   Complexity   

Complex Class

Complex classes like Schema often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Schema, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV4\edm;
4
5
/**
6
 * Class representing Schema
7
 */
8
class Schema
9
{
10
11
    /**
12
     * @property string $namespace
13
     */
14
    private $namespace = null;
15
16
    /**
17
     * @property string $alias
18
     */
19
    private $alias = null;
20
21
    /**
22
     * @property \MetadataV4\edm\TComplexTypeType[] $complexType
23
     */
24
    private $complexType = array(
25
        
26
    );
27
28
    /**
29
     * @property \MetadataV4\edm\TEntityTypeType[] $entityType
30
     */
31
    private $entityType = array(
32
        
33
    );
34
35
    /**
36
     * @property \MetadataV4\edm\TTypeDefinitionType[] $typeDefinition
37
     */
38
    private $typeDefinition = array(
39
        
40
    );
41
42
    /**
43
     * @property \MetadataV4\edm\TEnumTypeType[] $enumType
44
     */
45
    private $enumType = array(
46
        
47
    );
48
49
    /**
50
     * @property \MetadataV4\edm\TActionType[] $action
51
     */
52
    private $action = array(
53
        
54
    );
55
56
    /**
57
     * @property \MetadataV4\edm\TFunctionType[] $function
58
     */
59
    private $function = array(
60
        
61
    );
62
63
    /**
64
     * @property \MetadataV4\edm\TTermType[] $term
65
     */
66
    private $term = array(
67
        
68
    );
69
70
    /**
71
     * @property \MetadataV4\edm\TAnnotationsType[] $annotations
72
     */
73
    private $annotations = array(
74
        
75
    );
76
77
    /**
78
     * @property \MetadataV4\edm\TEntityContainerType[] $entityContainer
79
     */
80
    private $entityContainer = array(
81
        
82
    );
83
84
    /**
85
     * @property \MetadataV4\edm\Annotation[] $annotation
86
     */
87
    private $annotation = array(
88
        
89
    );
90
91
    /**
92
     * Gets as namespace
93
     *
94
     * @return string
95
     */
96
    public function getNamespace()
97
    {
98
        return $this->namespace;
99
    }
100
101
    /**
102
     * Sets a new namespace
103
     *
104
     * @param string $namespace
105
     * @return self
106
     */
107
    public function setNamespace($namespace)
108
    {
109
        $this->namespace = $namespace;
110
        return $this;
111
    }
112
113
    /**
114
     * Gets as alias
115
     *
116
     * @return string
117
     */
118
    public function getAlias()
119
    {
120
        return $this->alias;
121
    }
122
123
    /**
124
     * Sets a new alias
125
     *
126
     * @param string $alias
127
     * @return self
128
     */
129
    public function setAlias($alias)
130
    {
131
        $this->alias = $alias;
132
        return $this;
133
    }
134
135
    /**
136
     * Adds as complexType
137
     *
138
     * @return self
139
     * @param \MetadataV4\edm\TComplexTypeType $complexType
140
     */
141
    public function addToComplexType(\MetadataV4\edm\TComplexTypeType $complexType)
142
    {
143
        $this->complexType[] = $complexType;
144
        return $this;
145
    }
146
147
    /**
148
     * isset complexType
149
     *
150
     * @param scalar $index
151
     * @return boolean
152
     */
153
    public function issetComplexType($index)
154
    {
155
        return isset($this->complexType[$index]);
156
    }
157
158
    /**
159
     * unset complexType
160
     *
161
     * @param scalar $index
162
     * @return void
163
     */
164
    public function unsetComplexType($index)
165
    {
166
        unset($this->complexType[$index]);
167
    }
168
169
    /**
170
     * Gets as complexType
171
     *
172
     * @return \MetadataV4\edm\TComplexTypeType[]
173
     */
174
    public function getComplexType()
175
    {
176
        return $this->complexType;
177
    }
178
179
    /**
180
     * Sets a new complexType
181
     *
182
     * @param \MetadataV4\edm\TComplexTypeType[] $complexType
183
     * @return self
184
     */
185
    public function setComplexType(array $complexType)
186
    {
187
        $this->complexType = $complexType;
188
        return $this;
189
    }
190
191
    /**
192
     * Adds as entityType
193
     *
194
     * @return self
195
     * @param \MetadataV4\edm\TEntityTypeType $entityType
196
     */
197
    public function addToEntityType(\MetadataV4\edm\TEntityTypeType $entityType)
198
    {
199
        $this->entityType[] = $entityType;
200
        return $this;
201
    }
202
203
    /**
204
     * isset entityType
205
     *
206
     * @param scalar $index
207
     * @return boolean
208
     */
209
    public function issetEntityType($index)
210
    {
211
        return isset($this->entityType[$index]);
212
    }
213
214
    /**
215
     * unset entityType
216
     *
217
     * @param scalar $index
218
     * @return void
219
     */
220
    public function unsetEntityType($index)
221
    {
222
        unset($this->entityType[$index]);
223
    }
224
225
    /**
226
     * Gets as entityType
227
     *
228
     * @return \MetadataV4\edm\TEntityTypeType[]
229
     */
230
    public function getEntityType()
231
    {
232
        return $this->entityType;
233
    }
234
235
    /**
236
     * Sets a new entityType
237
     *
238
     * @param \MetadataV4\edm\TEntityTypeType[] $entityType
239
     * @return self
240
     */
241
    public function setEntityType(array $entityType)
242
    {
243
        $this->entityType = $entityType;
244
        return $this;
245
    }
246
247
    /**
248
     * Adds as typeDefinition
249
     *
250
     * @return self
251
     * @param \MetadataV4\edm\TTypeDefinitionType $typeDefinition
252
     */
253
    public function addToTypeDefinition(\MetadataV4\edm\TTypeDefinitionType $typeDefinition)
254
    {
255
        $this->typeDefinition[] = $typeDefinition;
256
        return $this;
257
    }
258
259
    /**
260
     * isset typeDefinition
261
     *
262
     * @param scalar $index
263
     * @return boolean
264
     */
265
    public function issetTypeDefinition($index)
266
    {
267
        return isset($this->typeDefinition[$index]);
268
    }
269
270
    /**
271
     * unset typeDefinition
272
     *
273
     * @param scalar $index
274
     * @return void
275
     */
276
    public function unsetTypeDefinition($index)
277
    {
278
        unset($this->typeDefinition[$index]);
279
    }
280
281
    /**
282
     * Gets as typeDefinition
283
     *
284
     * @return \MetadataV4\edm\TTypeDefinitionType[]
285
     */
286
    public function getTypeDefinition()
287
    {
288
        return $this->typeDefinition;
289
    }
290
291
    /**
292
     * Sets a new typeDefinition
293
     *
294
     * @param \MetadataV4\edm\TTypeDefinitionType[] $typeDefinition
295
     * @return self
296
     */
297
    public function setTypeDefinition(array $typeDefinition)
298
    {
299
        $this->typeDefinition = $typeDefinition;
300
        return $this;
301
    }
302
303
    /**
304
     * Adds as enumType
305
     *
306
     * @return self
307
     * @param \MetadataV4\edm\TEnumTypeType $enumType
308
     */
309
    public function addToEnumType(\MetadataV4\edm\TEnumTypeType $enumType)
310
    {
311
        $this->enumType[] = $enumType;
312
        return $this;
313
    }
314
315
    /**
316
     * isset enumType
317
     *
318
     * @param scalar $index
319
     * @return boolean
320
     */
321
    public function issetEnumType($index)
322
    {
323
        return isset($this->enumType[$index]);
324
    }
325
326
    /**
327
     * unset enumType
328
     *
329
     * @param scalar $index
330
     * @return void
331
     */
332
    public function unsetEnumType($index)
333
    {
334
        unset($this->enumType[$index]);
335
    }
336
337
    /**
338
     * Gets as enumType
339
     *
340
     * @return \MetadataV4\edm\TEnumTypeType[]
341
     */
342
    public function getEnumType()
343
    {
344
        return $this->enumType;
345
    }
346
347
    /**
348
     * Sets a new enumType
349
     *
350
     * @param \MetadataV4\edm\TEnumTypeType[] $enumType
351
     * @return self
352
     */
353
    public function setEnumType(array $enumType)
354
    {
355
        $this->enumType = $enumType;
356
        return $this;
357
    }
358
359
    /**
360
     * Adds as action
361
     *
362
     * @return self
363
     * @param \MetadataV4\edm\TActionType $action
364
     */
365
    public function addToAction(\MetadataV4\edm\TActionType $action)
366
    {
367
        $this->action[] = $action;
368
        return $this;
369
    }
370
371
    /**
372
     * isset action
373
     *
374
     * @param scalar $index
375
     * @return boolean
376
     */
377
    public function issetAction($index)
378
    {
379
        return isset($this->action[$index]);
380
    }
381
382
    /**
383
     * unset action
384
     *
385
     * @param scalar $index
386
     * @return void
387
     */
388
    public function unsetAction($index)
389
    {
390
        unset($this->action[$index]);
391
    }
392
393
    /**
394
     * Gets as action
395
     *
396
     * @return \MetadataV4\edm\TActionType[]
397
     */
398
    public function getAction()
399
    {
400
        return $this->action;
401
    }
402
403
    /**
404
     * Sets a new action
405
     *
406
     * @param \MetadataV4\edm\TActionType[] $action
407
     * @return self
408
     */
409
    public function setAction(array $action)
410
    {
411
        $this->action = $action;
412
        return $this;
413
    }
414
415
    /**
416
     * Adds as function
417
     *
418
     * @return self
419
     * @param \MetadataV4\edm\TFunctionType $function
420
     */
421
    public function addToFunction(\MetadataV4\edm\TFunctionType $function)
422
    {
423
        $this->function[] = $function;
424
        return $this;
425
    }
426
427
    /**
428
     * isset function
429
     *
430
     * @param scalar $index
431
     * @return boolean
432
     */
433
    public function issetFunction($index)
434
    {
435
        return isset($this->function[$index]);
436
    }
437
438
    /**
439
     * unset function
440
     *
441
     * @param scalar $index
442
     * @return void
443
     */
444
    public function unsetFunction($index)
445
    {
446
        unset($this->function[$index]);
447
    }
448
449
    /**
450
     * Gets as function
451
     *
452
     * @return \MetadataV4\edm\TFunctionType[]
453
     */
454
    public function getFunction()
455
    {
456
        return $this->function;
457
    }
458
459
    /**
460
     * Sets a new function
461
     *
462
     * @param \MetadataV4\edm\TFunctionType[] $function
463
     * @return self
464
     */
465
    public function setFunction(array $function)
466
    {
467
        $this->function = $function;
468
        return $this;
469
    }
470
471
    /**
472
     * Adds as term
473
     *
474
     * @return self
475
     * @param \MetadataV4\edm\TTermType $term
476
     */
477
    public function addToTerm(\MetadataV4\edm\TTermType $term)
478
    {
479
        $this->term[] = $term;
480
        return $this;
481
    }
482
483
    /**
484
     * isset term
485
     *
486
     * @param scalar $index
487
     * @return boolean
488
     */
489
    public function issetTerm($index)
490
    {
491
        return isset($this->term[$index]);
492
    }
493
494
    /**
495
     * unset term
496
     *
497
     * @param scalar $index
498
     * @return void
499
     */
500
    public function unsetTerm($index)
501
    {
502
        unset($this->term[$index]);
503
    }
504
505
    /**
506
     * Gets as term
507
     *
508
     * @return \MetadataV4\edm\TTermType[]
509
     */
510
    public function getTerm()
511
    {
512
        return $this->term;
513
    }
514
515
    /**
516
     * Sets a new term
517
     *
518
     * @param \MetadataV4\edm\TTermType[] $term
519
     * @return self
520
     */
521
    public function setTerm(array $term)
522
    {
523
        $this->term = $term;
524
        return $this;
525
    }
526
527
    /**
528
     * Adds as annotations
529
     *
530
     * @return self
531
     * @param \MetadataV4\edm\TAnnotationsType $annotations
532
     */
533
    public function addToAnnotations(\MetadataV4\edm\TAnnotationsType $annotations)
534
    {
535
        $this->annotations[] = $annotations;
536
        return $this;
537
    }
538
539
    /**
540
     * isset annotations
541
     *
542
     * @param scalar $index
543
     * @return boolean
544
     */
545
    public function issetAnnotations($index)
546
    {
547
        return isset($this->annotations[$index]);
548
    }
549
550
    /**
551
     * unset annotations
552
     *
553
     * @param scalar $index
554
     * @return void
555
     */
556
    public function unsetAnnotations($index)
557
    {
558
        unset($this->annotations[$index]);
559
    }
560
561
    /**
562
     * Gets as annotations
563
     *
564
     * @return \MetadataV4\edm\TAnnotationsType[]
565
     */
566
    public function getAnnotations()
567
    {
568
        return $this->annotations;
569
    }
570
571
    /**
572
     * Sets a new annotations
573
     *
574
     * @param \MetadataV4\edm\TAnnotationsType[] $annotations
575
     * @return self
576
     */
577
    public function setAnnotations(array $annotations)
578
    {
579
        $this->annotations = $annotations;
580
        return $this;
581
    }
582
583
    /**
584
     * Adds as entityContainer
585
     *
586
     * @return self
587
     * @param \MetadataV4\edm\TEntityContainerType $entityContainer
588
     */
589
    public function addToEntityContainer(\MetadataV4\edm\TEntityContainerType $entityContainer)
590
    {
591
        $this->entityContainer[] = $entityContainer;
592
        return $this;
593
    }
594
595
    /**
596
     * isset entityContainer
597
     *
598
     * @param scalar $index
599
     * @return boolean
600
     */
601
    public function issetEntityContainer($index)
602
    {
603
        return isset($this->entityContainer[$index]);
604
    }
605
606
    /**
607
     * unset entityContainer
608
     *
609
     * @param scalar $index
610
     * @return void
611
     */
612
    public function unsetEntityContainer($index)
613
    {
614
        unset($this->entityContainer[$index]);
615
    }
616
617
    /**
618
     * Gets as entityContainer
619
     *
620
     * @return \MetadataV4\edm\TEntityContainerType[]
621
     */
622
    public function getEntityContainer()
623
    {
624
        return $this->entityContainer;
625
    }
626
627
    /**
628
     * Sets a new entityContainer
629
     *
630
     * @param \MetadataV4\edm\TEntityContainerType[] $entityContainer
631
     * @return self
632
     */
633
    public function setEntityContainer(array $entityContainer)
634
    {
635
        $this->entityContainer = $entityContainer;
636
        return $this;
637
    }
638
639
    /**
640
     * Adds as annotation
641
     *
642
     * @return self
643
     * @param \MetadataV4\edm\Annotation $annotation
644
     */
645
    public function addToAnnotation(\MetadataV4\edm\Annotation $annotation)
646
    {
647
        $this->annotation[] = $annotation;
648
        return $this;
649
    }
650
651
    /**
652
     * isset annotation
653
     *
654
     * @param scalar $index
655
     * @return boolean
656
     */
657
    public function issetAnnotation($index)
658
    {
659
        return isset($this->annotation[$index]);
660
    }
661
662
    /**
663
     * unset annotation
664
     *
665
     * @param scalar $index
666
     * @return void
667
     */
668
    public function unsetAnnotation($index)
669
    {
670
        unset($this->annotation[$index]);
671
    }
672
673
    /**
674
     * Gets as annotation
675
     *
676
     * @return \MetadataV4\edm\Annotation[]
677
     */
678
    public function getAnnotation()
679
    {
680
        return $this->annotation;
681
    }
682
683
    /**
684
     * Sets a new annotation
685
     *
686
     * @param \MetadataV4\edm\Annotation[] $annotation
687
     * @return self
688
     */
689
    public function setAnnotation(array $annotation)
690
    {
691
        $this->annotation = $annotation;
692
        return $this;
693
    }
694
}
695