Completed
Pull Request — develop (#199)
by Wachter
13:59
created

ArticleViewDocument   C

Complexity

Total Complexity 53

Size/Duplication

Total Lines 711
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 53
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 711
ccs 128
cts 128
cp 1
rs 5.7142

53 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 1
A setId() 0 6 1
A getUuid() 0 4 1
A setUuid() 0 6 1
A getLocale() 0 4 1
A setLocale() 0 6 1
A getTitle() 0 4 1
A setTitle() 0 6 1
A getRoutePath() 0 4 1
A setRoutePath() 0 4 1
A getParentPageUuid() 0 4 1
A setParentPageUuid() 0 6 1
A getType() 0 4 1
A setType() 0 6 1
A getTypeTranslation() 0 4 1
A setTypeTranslation() 0 6 1
A getStructureType() 0 4 1
A setStructureType() 0 6 1
A getChangerFullName() 0 4 1
A setChangerFullName() 0 6 1
A getCreatorFullName() 0 4 1
A setCreatorFullName() 0 6 1
A getChanged() 0 4 1
A setChanged() 0 6 1
A getCreated() 0 4 1
A setCreated() 0 6 1
A getExcerpt() 0 4 1
A setExcerpt() 0 6 1
A getSeo() 0 4 1
A setSeo() 0 6 1
A getAuthored() 0 4 1
A setAuthored() 0 6 1
A getAuthorFullName() 0 4 1
A setAuthorFullName() 0 6 1
A getTeaserDescription() 0 4 1
A setTeaserDescription() 0 6 1
A getTeaserMediaId() 0 4 1
A setTeaserMediaId() 0 4 1
A getPublished() 0 4 1
A setPublished() 0 6 1
A getPublishedState() 0 4 1
A setPublishedState() 0 6 1
A getLocalizationState() 0 4 1
A setLocalizationState() 0 6 1
A setAuthorId() 0 6 1
A getAuthorId() 0 4 1
A setCreatorContactId() 0 6 1
A getCreatorContactId() 0 4 1
A setChangerContactId() 0 6 1
A getChangerContactId() 0 4 1
A getPages() 0 4 1
A setPages() 0 6 1

How to fix   Complexity   

Complex Class

Complex classes like ArticleViewDocument 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 ArticleViewDocument, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Bundle\ArticleBundle\Document;
13
14
use ONGR\ElasticsearchBundle\Annotation\Document;
15
use ONGR\ElasticsearchBundle\Annotation\Embedded;
16
use ONGR\ElasticsearchBundle\Annotation\Id;
17
use ONGR\ElasticsearchBundle\Annotation\Property;
18
use ONGR\ElasticsearchBundle\Collection\Collection;
19
20
/**
21
 * Indexable document for articles.
22
 *
23
 * @Document(type="article")
24
 */
25
class ArticleViewDocument implements ArticleViewDocumentInterface
26
{
27
    /**
28
     * @var string
29
     *
30
     * @Id
31
     */
32
    protected $id;
33
34
    /**
35
     * @var string
36
     *
37
     * @Property(type="string", options={"analyzer": "keyword"})
38
     */
39
    protected $uuid;
40
41
    /**
42
     * @var string
43
     *
44
     * @Property(type="string", options={"analyzer": "keyword"})
45
     */
46
    protected $locale;
47
48
    /**
49
     * @var string
50
     *
51
     * @Property(
52
     *     type="string",
53
     *     options={
54
     *         "fields":{
55
     *            "raw":{"type":"string", "index":"not_analyzed"},
56
     *            "value":{"type":"string"}
57
     *         }
58
     *     }
59
     * )
60
     */
61
    protected $title;
62
63
    /**
64
     * @var string
65
     *
66
     * @Property(
67
     *     type="string",
68
     *     options={
69
     *         "fields":{
70
     *            "raw":{"type":"string", "index":"not_analyzed"},
71
     *            "value":{"type":"string"}
72
     *         }
73
     *     }
74
     * )
75
     */
76
    protected $routePath;
77
78
    /**
79
     * @var string
80
     *
81
     * @Property(type="string", options={"analyzer": "keyword"})
82
     */
83
    protected $parentPageUuid;
84
85
    /**
86
     * @var string
87
     *
88
     * @Property(
89
     *     type="string",
90
     *     options={
91
     *         "analyzer":"keyword"
92
     *     }
93
     * )
94
     */
95
    protected $type;
96
97
    /**
98
     * @var string
99
     *
100
     * @Property(
101
     *     type="string",
102
     *     options={
103
     *         "analyzer":"keyword"
104
     *     }
105
     * )
106
     */
107
    protected $typeTranslation;
108
109
    /**
110
     * @var string
111
     *
112
     * @Property(
113
     *     type="string",
114
     *     options={
115
     *         "analyzer":"keyword"
116
     *     }
117
     * )
118
     */
119
    protected $structureType;
120
121
    /**
122
     * @var string
123
     *
124
     * @Property(
125
     *     type="string",
126
     *     options={
127
     *         "fields":{
128
     *            "raw":{"type":"string", "index":"not_analyzed"},
129
     *            "value":{"type":"string"}
130
     *         }
131
     *     }
132
     * )
133
     */
134
    protected $changerFullName;
135
136
    /**
137
     * @var string
138
     *
139
     * @Property(
140
     *     type="string",
141
     *     options={
142
     *         "fields":{
143
     *            "raw":{"type":"string", "index":"not_analyzed"},
144
     *            "value":{"type":"string"}
145
     *         }
146
     *     }
147
     * )
148
     */
149
    protected $creatorFullName;
150
151
    /**
152
     * @var \DateTime
153
     *
154
     * @Property(type="date")
155
     */
156
    protected $changed;
157
158
    /**
159
     * @var \DateTime
160
     *
161
     * @Property(type="date")
162
     */
163
    protected $created;
164
165
    /**
166
     * @var ExcerptViewObject
167
     *
168
     * @Embedded(class="SuluArticleBundle:ExcerptViewObject")
169
     */
170
    protected $excerpt;
171
172
    /**
173
     * @var SeoViewObject
174
     *
175
     * @Embedded(class="SuluArticleBundle:SeoViewObject")
176
     */
177
    protected $seo;
178
179
    /**
180
     * @var \DateTime
181
     *
182
     * @Property(type="date")
183
     */
184
    protected $authored;
185
186
    /**
187
     * @var string
188
     *
189
     * @Property(
190
     *     type="string",
191
     *     options={
192
     *         "fields":{
193
     *            "raw":{"type":"string", "index":"not_analyzed"},
194
     *            "value":{"type":"string"}
195
     *         }
196
     *     }
197
     * )
198
     */
199
    protected $authorFullName;
200
201
    /**
202
     * @var string
203
     *
204
     * @Property(type="string")
205
     */
206
    protected $teaserDescription = '';
207
208
    /**
209
     * @var int
210
     *
211
     * @Property(type="integer")
212
     */
213
    protected $teaserMediaId;
214
215
    /**
216
     * @var \DateTime
217
     *
218
     * @Property(type="date")
219
     */
220
    protected $published;
221
222
    /**
223
     * @var bool
224
     *
225
     * @Property(type="boolean")
226
     */
227
    protected $publishedState;
228
229
    /**
230
     * @var LocalizationStateViewObject
231
     *
232
     * @Embedded(class="SuluArticleBundle:LocalizationStateViewObject")
233
     */
234
    protected $localizationState;
235
236
    /**
237
     * @var string
238
     *
239
     * @Property(type="string")
240
     */
241
    protected $authorId;
242
243
    /**
244
     * @var string
245
     *
246
     * @Property(type="string")
247
     */
248
    protected $creatorContactId;
249
250
    /**
251
     * @var string
252
     *
253
     * @Property(type="string")
254
     */
255
    protected $changerContactId;
256
257
    /**
258
     * @var ArticlePageViewObject[]
259
     *
260 51
     * @Embedded(class="SuluArticleBundle:ArticlePageViewObject", multiple=true)
261
     */
262 51
    protected $pages = [];
263 51
264
    /**
265
     * @param string $uuid
266
     */
267
    public function __construct($uuid = null)
268 50
    {
269
        $this->uuid = $uuid;
270 50
    }
271
272
    /**
273
     * {@inheritdoc}
274
     */
275
    public function getId()
276 50
    {
277
        return $this->id;
278 50
    }
279
280 50
    /**
281
     * {@inheritdoc}
282
     */
283
    public function setId($id)
284
    {
285
        $this->id = $id;
286 51
287
        return $this;
288 51
    }
289
290
    /**
291
     * {@inheritdoc}
292
     */
293
    public function getUuid()
294 50
    {
295
        return $this->uuid;
296 50
    }
297
298 50
    /**
299
     * {@inheritdoc}
300
     */
301
    public function setUuid($uuid)
302
    {
303
        $this->uuid = $uuid;
304 50
305
        return $this;
306 50
    }
307
308
    /**
309
     * {@inheritdoc}
310
     */
311
    public function getLocale()
312 50
    {
313
        return $this->locale;
314 50
    }
315
316 50
    /**
317
     * {@inheritdoc}
318
     */
319
    public function setLocale($locale)
320
    {
321
        $this->locale = $locale;
322 50
323
        return $this;
324 50
    }
325
326
    /**
327
     * {@inheritdoc}
328
     */
329
    public function getTitle()
330 50
    {
331
        return $this->title;
332 50
    }
333
334 50
    /**
335
     * {@inheritdoc}
336
     */
337
    public function setTitle($title)
338
    {
339
        $this->title = $title;
340 50
341
        return $this;
342 50
    }
343
344
    /**
345
     * {@inheritdoc}
346
     */
347
    public function getRoutePath()
348 50
    {
349
        return $this->routePath;
350 50
    }
351 50
352
    /**
353
     * {@inheritdoc}
354
     */
355
    public function setRoutePath($routePath)
356 50
    {
357
        $this->routePath = $routePath;
358 50
    }
359
360
    /**
361
     * {@inheritdoc}
362
     */
363
    public function getParentPageUuid()
364 50
    {
365
        return $this->parentPageUuid;
366 50
    }
367
368 50
    /**
369
     * {@inheritdoc}
370
     */
371
    public function setParentPageUuid($parentPageUuid)
372
    {
373
        $this->parentPageUuid = $parentPageUuid;
374 50
375
        return $this;
376 50
    }
377
378
    /**
379
     * {@inheritdoc}
380
     */
381
    public function getType()
382 50
    {
383
        return $this->type;
384 50
    }
385
386 50
    /**
387
     * {@inheritdoc}
388
     */
389
    public function setType($type)
390
    {
391
        $this->type = $type;
392 50
393
        return $this;
394 50
    }
395
396
    /**
397
     * {@inheritdoc}
398
     */
399
    public function getTypeTranslation()
400 50
    {
401
        return $this->typeTranslation;
402 50
    }
403
404 50
    /**
405
     * {@inheritdoc}
406
     */
407
    public function setTypeTranslation($typeTranslation)
408
    {
409
        $this->typeTranslation = $typeTranslation;
410 50
411
        return $this;
412 50
    }
413
414
    /**
415
     * {@inheritdoc}
416
     */
417
    public function getStructureType()
418 50
    {
419
        return $this->structureType;
420 50
    }
421
422 50
    /**
423
     * {@inheritdoc}
424
     */
425
    public function setStructureType($structureType)
426
    {
427
        $this->structureType = $structureType;
428 50
429
        return $this;
430 50
    }
431
432
    /**
433
     * {@inheritdoc}
434
     */
435
    public function getChangerFullName()
436 50
    {
437
        return $this->changerFullName;
438 50
    }
439
440 50
    /**
441
     * {@inheritdoc}
442
     */
443
    public function setChangerFullName($changerFullName)
444
    {
445
        $this->changerFullName = $changerFullName;
446 50
447
        return $this;
448 50
    }
449
450
    /**
451
     * {@inheritdoc}
452
     */
453
    public function getCreatorFullName()
454 50
    {
455
        return $this->creatorFullName;
456 50
    }
457
458 50
    /**
459
     * {@inheritdoc}
460
     */
461
    public function setCreatorFullName($creatorFullName)
462
    {
463
        $this->creatorFullName = $creatorFullName;
464 50
465
        return $this;
466 50
    }
467
468
    /**
469
     * {@inheritdoc}
470
     */
471
    public function getChanged()
472 50
    {
473
        return $this->changed;
474 50
    }
475
476 50
    /**
477
     * {@inheritdoc}
478
     */
479
    public function setChanged($changed)
480
    {
481
        $this->changed = $changed;
482 50
483
        return $this;
484 50
    }
485
486
    /**
487
     * {@inheritdoc}
488
     */
489
    public function getCreated()
490 50
    {
491
        return $this->created;
492 50
    }
493
494 50
    /**
495
     * {@inheritdoc}
496
     */
497
    public function setCreated($created)
498
    {
499
        $this->created = $created;
500 50
501
        return $this;
502 50
    }
503
504
    /**
505
     * {@inheritdoc}
506
     */
507
    public function getExcerpt()
508 50
    {
509
        return $this->excerpt;
510 50
    }
511
512 50
    /**
513
     * {@inheritdoc}
514
     */
515
    public function setExcerpt(ExcerptViewObject $excerpt)
516
    {
517
        $this->excerpt = $excerpt;
518 50
519
        return $this;
520 50
    }
521
522
    /**
523
     * {@inheritdoc}
524
     */
525
    public function getSeo()
526 50
    {
527
        return $this->seo;
528 50
    }
529
530 50
    /**
531
     * {@inheritdoc}
532
     */
533
    public function setSeo(SeoViewObject $seo)
534
    {
535
        $this->seo = $seo;
536 50
537
        return $this;
538 50
    }
539
540
    /**
541
     * {@inheritdoc}
542
     */
543
    public function getAuthored()
544 50
    {
545
        return $this->authored;
546 50
    }
547
548 50
    /**
549
     * {@inheritdoc}
550
     */
551
    public function setAuthored(\DateTime $authored = null)
552
    {
553
        $this->authored = $authored;
554 50
555
        return $this;
556 50
    }
557
558
    /**
559
     * {@inheritdoc}
560
     */
561
    public function getAuthorFullName()
562 44
    {
563
        return $this->authorFullName;
564 44
    }
565
566 44
    /**
567
     * {@inheritdoc}
568
     */
569
    public function setAuthorFullName($authorFullName)
570
    {
571
        $this->authorFullName = $authorFullName;
572 50
573
        return $this;
574 50
    }
575
576
    /**
577
     * {@inheritdoc}
578
     */
579
    public function getTeaserDescription()
580 1
    {
581
        return $this->teaserDescription;
582 1
    }
583 1
584
    /**
585
     * {@inheritdoc}
586
     */
587
    public function setTeaserDescription($teaserDescription)
588 50
    {
589
        $this->teaserDescription = $teaserDescription;
590 50
591
        return $this;
592
    }
593
594
    /**
595
     * {@inheritdoc}
596 50
     */
597
    public function getTeaserMediaId()
598 50
    {
599
        return $this->teaserMediaId;
600 50
    }
601
602
    /**
603
     * {@inheritdoc}
604
     */
605
    public function setTeaserMediaId($teaserMediaId)
606 50
    {
607
        $this->teaserMediaId = $teaserMediaId;
608 50
    }
609
610
    /**
611
     * {@inheritdoc}
612
     */
613
    public function getPublished()
614 50
    {
615
        return $this->published;
616 50
    }
617
618 50
    /**
619
     * {@inheritdoc}
620
     */
621
    public function setPublished(\DateTime $published = null)
622
    {
623
        $this->published = $published;
624 50
625
        return $this;
626 50
    }
627
628
    /**
629
     * {@inheritdoc}
630
     */
631
    public function getPublishedState()
632 50
    {
633
        return $this->publishedState;
634 50
    }
635
636 50
    /**
637
     * {@inheritdoc}
638
     */
639
    public function setPublishedState($publishedState)
640
    {
641
        $this->publishedState = $publishedState;
642 50
643
        return $this;
644 50
    }
645
646 50
    /**
647
     * {@inheritdoc}
648
     */
649
    public function getLocalizationState()
650
    {
651
        return $this->localizationState;
652 50
    }
653
654 50
    /**
655
     * {@inheritdoc}
656
     */
657
    public function setLocalizationState(LocalizationStateViewObject $localizationState)
658
    {
659
        $this->localizationState = $localizationState;
660 50
661
        return $this;
662 50
    }
663
664 50
    /**
665
     * {@inheritdoc}
666
     */
667
    public function setAuthorId($authorId)
668
    {
669
        $this->authorId = $authorId;
670 50
671
        return $this;
672 50
    }
673
674
    /**
675
     * {@inheritdoc}
676
     */
677
    public function getAuthorId()
678 50
    {
679
        return $this->authorId;
680 50
    }
681
682 50
    /**
683
     * {@inheritdoc}
684
     */
685
    public function setCreatorContactId($creatorContactId)
686
    {
687
        $this->creatorContactId = $creatorContactId;
688 50
689
        return $this;
690 50
    }
691
692
    /**
693
     * {@inheritdoc}
694
     */
695
    public function getCreatorContactId()
696 50
    {
697
        return $this->creatorContactId;
698 50
    }
699
700
    /**
701
     * {@inheritdoc}
702
     */
703
    public function setChangerContactId($changerContactId)
704 50
    {
705
        $this->changerContactId = $changerContactId;
706 50
707
        return $this;
708 50
    }
709
710
    /**
711
     * {@inheritdoc}
712
     */
713
    public function getChangerContactId()
714
    {
715
        return $this->changerContactId;
716
    }
717
718
    /**
719
     * {@inheritdoc}
720
     */
721
    public function getPages()
722
    {
723
        return $this->pages;
724
    }
725
726
    /**
727
     * {@inheritdoc}
728
     */
729
    public function setPages(Collection $pages)
730
    {
731
        $this->pages = $pages;
0 ignored issues
show
Documentation Bug introduced by
It seems like $pages of type object<ONGR\Elasticsearc...\Collection\Collection> is incompatible with the declared type array<integer,object<Sul...ArticlePageViewObject>> of property $pages.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
732
733
        return $this;
734
    }
735
}
736