Completed
Branch develop (45165d)
by Alexey
04:09
created

AppBuilder   F

Complexity

Total Complexity 77

Size/Duplication

Total Lines 819
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 77
eloc 157
dl 0
loc 819
rs 2.24
c 0
b 0
f 0

73 Methods

Rating   Name   Duplication   Size   Complexity  
A getPriceText() 0 3 1
A isEditorsChoice() 0 3 1
A setReviews() 0 7 2
A addReview() 0 4 1
A getName() 0 3 1
A getCategory() 0 3 1
A getContentRating() 0 3 1
A setLocale() 0 4 1
A getHeaderImage() 0 3 1
A getReleased() 0 3 1
A setHistogramRating() 0 4 1
A getPrice() 0 3 1
A setUpdated() 0 4 1
A getLocale() 0 3 1
A getCategoryFamily() 0 3 1
A setPrivacyPoliceUrl() 0 4 1
A setContentRating() 0 4 1
A setOffersIAPCost() 0 4 1
A getId() 0 3 1
A getHistogramRating() 0 3 1
A setId() 0 5 1
A getScreenshots() 0 3 1
A getPrivacyPoliceUrl() 0 3 1
A getReviews() 0 3 1
A getUrl() 0 3 1
A setNumberVoters() 0 4 1
A getOffersIAPCost() 0 3 1
A getDescription() 0 3 1
A getSummary() 0 3 1
A setEditorsChoice() 0 4 1
A getAndroidVersion() 0 3 1
A setAppVersion() 0 4 1
A setName() 0 4 1
A getInstalls() 0 3 1
A getDeveloper() 0 3 1
A setMinAndroidVersion() 0 4 1
A setInstalls() 0 4 1
A setPriceText() 0 4 1
A getVideo() 0 3 1
A isAdSupported() 0 3 1
A getAppSize() 0 3 1
A setDeveloper() 0 4 1
A setReleased() 0 4 1
A setAndroidVersion() 0 4 1
A getTranslatedFromLanguage() 0 3 1
A setPrice() 0 4 1
A setScore() 0 4 1
A getMinAndroidVersion() 0 3 1
A setScreenshots() 0 7 2
A setTranslated() 0 12 3
A setDescription() 0 4 1
A getIcon() 0 3 1
A setSummary() 0 4 1
A getCurrency() 0 3 1
A setVideo() 0 4 1
A setRecentChanges() 0 4 1
A setAppSize() 0 4 1
A getReviewsCount() 0 3 1
A setCategory() 0 4 1
A getAppVersion() 0 3 1
A setReviewsCount() 0 4 1
A setCurrency() 0 4 1
A getUpdated() 0 3 1
A addScreenshot() 0 4 1
A setIcon() 0 4 1
A setHeaderImage() 0 4 1
A getRecentChanges() 0 3 1
A getNumberVoters() 0 3 1
A setCategoryFamily() 0 4 1
A getScore() 0 3 1
A getTranslatedDescription() 0 3 1
A setAdSupported() 0 4 1
A setUrl() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like AppBuilder 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.

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 AppBuilder, and based on these observations, apply Extract Interface, too.

1
<?php
2
declare(strict_types=1);
3
4
namespace Nelexa\GPlay\Model\Builder;
5
6
use Nelexa\GPlay\GPlayApps;
7
use Nelexa\GPlay\Model\Category;
8
use Nelexa\GPlay\Model\Developer;
9
use Nelexa\GPlay\Model\GoogleImage;
10
use Nelexa\GPlay\Model\HistogramRating;
11
use Nelexa\GPlay\Model\Review;
12
use Nelexa\GPlay\Model\Video;
13
14
class AppBuilder
15
{
16
    /**
17
     * @var string|null
18
     */
19
    private $id;
20
    /**
21
     * @var string|null
22
     */
23
    private $url;
24
    /**
25
     * @var string|null
26
     */
27
    private $name;
28
    /**
29
     * @var string|null
30
     */
31
    private $summary;
32
    /**
33
     * @var Developer|null
34
     */
35
    private $developer;
36
    /**
37
     * @var GoogleImage|null
38
     */
39
    private $icon;
40
    /**
41
     * @var float
42
     */
43
    private $score = 0.0;
44
    /**
45
     * @var string|null
46
     */
47
    private $priceText;
48
    /**
49
     * @var string|null
50
     */
51
    private $locale;
52
    /**
53
     * @var string|null
54
     */
55
    private $description;
56
    /**
57
     * @var string|null
58
     */
59
    private $translatedDescription;
60
    /**
61
     * @var string|null
62
     */
63
    private $translatedFromLanguage;
64
    /**
65
     * @var GoogleImage|null
66
     */
67
    private $headerImage;
68
    /**
69
     * @var GoogleImage[]
70
     */
71
    private $screenshots = [];
72
    /**
73
     * @var Category|null
74
     */
75
    private $category;
76
    /**
77
     * @var string|null
78
     */
79
    private $privacyPoliceUrl;
80
    /**
81
     * @var Category|null
82
     */
83
    private $categoryFamily;
84
    /**
85
     * @var Video|null
86
     */
87
    private $video;
88
    /**
89
     * @var string|null
90
     */
91
    private $recentChanges;
92
    /**
93
     * @var bool
94
     */
95
    private $editorsChoice = false;
96
    /**
97
     * @var int
98
     */
99
    private $installs = 0;
100
    /**
101
     * @var int
102
     */
103
    private $numberVoters = 0;
104
    /**
105
     * @var HistogramRating|null
106
     */
107
    private $histogramRating;
108
    /**
109
     * @var float
110
     */
111
    private $price = 0;
112
    /**
113
     * @var string|null
114
     */
115
    private $currency;
116
    /**
117
     * @var string|null
118
     */
119
    private $offersIAPCost;
120
    /**
121
     * @var bool
122
     */
123
    private $adSupported = false;
124
    /**
125
     * @var string|null
126
     */
127
    private $appSize;
128
    /**
129
     * @var string|null
130
     */
131
    private $appVersion;
132
    /**
133
     * @var string|null
134
     */
135
    private $androidVersion;
136
    /**
137
     * @var string|null
138
     */
139
    private $minAndroidVersion;
140
    /**
141
     * @var string|null
142
     */
143
    private $contentRating;
144
    /**
145
     * @var \DateTimeInterface|null
146
     */
147
    private $released;
148
    /**
149
     * @var \DateTimeInterface|null
150
     */
151
    private $updated;
152
    /**
153
     * @var int
154
     */
155
    private $reviewsCount = 0;
156
    /**
157
     * @var Review[]
158
     */
159
    private $reviews = [];
160
161
    /**
162
     * @return string|null
163
     */
164
    public function getId(): ?string
165
    {
166
        return $this->id;
167
    }
168
169
    /**
170
     * @param string $id
171
     * @return AppBuilder
172
     */
173
    public function setId(string $id): AppBuilder
174
    {
175
        $this->id = $id;
176
        $this->url = GPlayApps::GOOGLE_PLAY_APPS_URL . '/details?id=' . $id;
177
        return $this;
178
    }
179
180
    /**
181
     * @param string|null $url
182
     * @return AppBuilder
183
     */
184
    public function setUrl(?string $url): AppBuilder
185
    {
186
        $this->url = $url;
187
        return $this;
188
    }
189
190
    /**
191
     * @return string|null
192
     */
193
    public function getUrl(): ?string
194
    {
195
        return $this->url;
196
    }
197
198
    /**
199
     * @return string|null
200
     */
201
    public function getName(): ?string
202
    {
203
        return $this->name;
204
    }
205
206
    /**
207
     * @param string|null $name
208
     * @return AppBuilder
209
     */
210
    public function setName(?string $name): AppBuilder
211
    {
212
        $this->name = $name;
213
        return $this;
214
    }
215
216
    /**
217
     * @return string|null
218
     */
219
    public function getSummary(): ?string
220
    {
221
        return $this->summary;
222
    }
223
224
    /**
225
     * @param string|null $summary
226
     * @return AppBuilder
227
     */
228
    public function setSummary(?string $summary): AppBuilder
229
    {
230
        $this->summary = $summary;
231
        return $this;
232
    }
233
234
    /**
235
     * @return Developer|null
236
     */
237
    public function getDeveloper(): ?Developer
238
    {
239
        return $this->developer;
240
    }
241
242
    /**
243
     * @param Developer|null $developer
244
     * @return AppBuilder
245
     */
246
    public function setDeveloper(?Developer $developer): AppBuilder
247
    {
248
        $this->developer = $developer;
249
        return $this;
250
    }
251
252
    /**
253
     * @return GoogleImage|null
254
     */
255
    public function getIcon(): ?GoogleImage
256
    {
257
        return $this->icon;
258
    }
259
260
    /**
261
     * @param GoogleImage|null $icon
262
     * @return AppBuilder
263
     */
264
    public function setIcon(?GoogleImage $icon): AppBuilder
265
    {
266
        $this->icon = $icon;
267
        return $this;
268
    }
269
270
    /**
271
     * @return float
272
     */
273
    public function getScore(): float
274
    {
275
        return $this->score;
276
    }
277
278
    /**
279
     * @param float $score
280
     * @return AppBuilder
281
     */
282
    public function setScore(float $score): AppBuilder
283
    {
284
        $this->score = $score;
285
        return $this;
286
    }
287
288
    /**
289
     * @return string|null
290
     */
291
    public function getPriceText(): ?string
292
    {
293
        return $this->priceText;
294
    }
295
296
    /**
297
     * @param string|null $priceText
298
     * @return AppBuilder
299
     */
300
    public function setPriceText(?string $priceText): AppBuilder
301
    {
302
        $this->priceText = $priceText;
303
        return $this;
304
    }
305
306
    /**
307
     * @return string|null
308
     */
309
    public function getLocale(): ?string
310
    {
311
        return $this->locale;
312
    }
313
314
    /**
315
     * @param string|null $locale
316
     * @return AppBuilder
317
     */
318
    public function setLocale(?string $locale): AppBuilder
319
    {
320
        $this->locale = $locale;
321
        return $this;
322
    }
323
324
    /**
325
     * @return string|null
326
     */
327
    public function getDescription(): ?string
328
    {
329
        return $this->description;
330
    }
331
332
    /**
333
     * @param string|null $description
334
     * @return AppBuilder
335
     */
336
    public function setDescription(?string $description): AppBuilder
337
    {
338
        $this->description = $description;
339
        return $this;
340
    }
341
342
    /**
343
     * @return string|null
344
     */
345
    public function getTranslatedDescription(): ?string
346
    {
347
        return $this->translatedDescription;
348
    }
349
350
    /**
351
     * @return string|null
352
     */
353
    public function getTranslatedFromLanguage(): ?string
354
    {
355
        return $this->translatedFromLanguage;
356
    }
357
358
    /**
359
     * @param string|null $translatedDescription
360
     * @param string|null $translatedFromLanguage
361
     * @return AppBuilder
362
     */
363
    public function setTranslated(
364
        ?string $translatedDescription,
365
        ?string $translatedFromLanguage
366
    ): AppBuilder {
367
        if ($translatedFromLanguage === null || $translatedDescription === null) {
368
            $this->translatedDescription = null;
369
            $this->translatedFromLanguage = null;
370
        } else {
371
            $this->translatedDescription = $translatedDescription;
372
            $this->translatedFromLanguage = $translatedFromLanguage;
373
        }
374
        return $this;
375
    }
376
377
    /**
378
     * @return GoogleImage|null
379
     */
380
    public function getHeaderImage(): ?GoogleImage
381
    {
382
        return $this->headerImage;
383
    }
384
385
    /**
386
     * @param GoogleImage|null $headerImage
387
     * @return AppBuilder
388
     */
389
    public function setHeaderImage(?GoogleImage $headerImage): AppBuilder
390
    {
391
        $this->headerImage = $headerImage;
392
        return $this;
393
    }
394
395
    /**
396
     * @return GoogleImage[]
397
     */
398
    public function getScreenshots(): array
399
    {
400
        return $this->screenshots;
401
    }
402
403
    /**
404
     * @param GoogleImage[] $screenshots
405
     * @return AppBuilder
406
     */
407
    public function setScreenshots(array $screenshots): AppBuilder
408
    {
409
        $this->screenshots = [];
410
        foreach ($screenshots as $screenshot) {
411
            $this->addScreenshot($screenshot);
412
        }
413
        return $this;
414
    }
415
416
    /**
417
     * @param GoogleImage $image
418
     * @return AppBuilder
419
     */
420
    public function addScreenshot(GoogleImage $image): AppBuilder
421
    {
422
        $this->screenshots[] = $image;
423
        return $this;
424
    }
425
426
    /**
427
     * @return Category|null
428
     */
429
    public function getCategory(): ?Category
430
    {
431
        return $this->category;
432
    }
433
434
    /**
435
     * @param Category|null $category
436
     * @return AppBuilder
437
     */
438
    public function setCategory(?Category $category): AppBuilder
439
    {
440
        $this->category = $category;
441
        return $this;
442
    }
443
444
    /**
445
     * @return string|null
446
     */
447
    public function getPrivacyPoliceUrl(): ?string
448
    {
449
        return $this->privacyPoliceUrl;
450
    }
451
452
    /**
453
     * @param string|null $privacyPoliceUrl
454
     * @return AppBuilder
455
     */
456
    public function setPrivacyPoliceUrl(?string $privacyPoliceUrl): AppBuilder
457
    {
458
        $this->privacyPoliceUrl = $privacyPoliceUrl;
459
        return $this;
460
    }
461
462
    /**
463
     * @return Category|null
464
     */
465
    public function getCategoryFamily(): ?Category
466
    {
467
        return $this->categoryFamily;
468
    }
469
470
    /**
471
     * @param Category|null $categoryFamily
472
     * @return AppBuilder
473
     */
474
    public function setCategoryFamily(?Category $categoryFamily): AppBuilder
475
    {
476
        $this->categoryFamily = $categoryFamily;
477
        return $this;
478
    }
479
480
    /**
481
     * @return Video|null
482
     */
483
    public function getVideo(): ?Video
484
    {
485
        return $this->video;
486
    }
487
488
    /**
489
     * @param Video|null $video
490
     * @return AppBuilder
491
     */
492
    public function setVideo(?Video $video): AppBuilder
493
    {
494
        $this->video = $video;
495
        return $this;
496
    }
497
498
    /**
499
     * @return string|null
500
     */
501
    public function getRecentChanges(): ?string
502
    {
503
        return $this->recentChanges;
504
    }
505
506
    /**
507
     * @param string|null $recentChanges
508
     * @return AppBuilder
509
     */
510
    public function setRecentChanges(?string $recentChanges): AppBuilder
511
    {
512
        $this->recentChanges = $recentChanges;
513
        return $this;
514
    }
515
516
    /**
517
     * @return bool
518
     */
519
    public function isEditorsChoice(): bool
520
    {
521
        return $this->editorsChoice;
522
    }
523
524
    /**
525
     * @param bool $editorsChoice
526
     * @return AppBuilder
527
     */
528
    public function setEditorsChoice(bool $editorsChoice): AppBuilder
529
    {
530
        $this->editorsChoice = $editorsChoice;
531
        return $this;
532
    }
533
534
    /**
535
     * @return int
536
     */
537
    public function getInstalls(): int
538
    {
539
        return $this->installs;
540
    }
541
542
    /**
543
     * @param int $installs
544
     * @return AppBuilder
545
     */
546
    public function setInstalls(int $installs): AppBuilder
547
    {
548
        $this->installs = $installs;
549
        return $this;
550
    }
551
552
    /**
553
     * @return int
554
     */
555
    public function getNumberVoters(): int
556
    {
557
        return $this->numberVoters;
558
    }
559
560
    /**
561
     * @param int $numberVoters
562
     * @return AppBuilder
563
     */
564
    public function setNumberVoters(int $numberVoters): AppBuilder
565
    {
566
        $this->numberVoters = $numberVoters;
567
        return $this;
568
    }
569
570
    /**
571
     * @return HistogramRating|null
572
     */
573
    public function getHistogramRating(): ?HistogramRating
574
    {
575
        return $this->histogramRating;
576
    }
577
578
    /**
579
     * @param HistogramRating|null $histogramRating
580
     * @return AppBuilder
581
     */
582
    public function setHistogramRating(?HistogramRating $histogramRating): AppBuilder
583
    {
584
        $this->histogramRating = $histogramRating;
585
        return $this;
586
    }
587
588
    /**
589
     * @return float
590
     */
591
    public function getPrice(): float
592
    {
593
        return $this->price;
594
    }
595
596
    /**
597
     * @param float $price
598
     * @return AppBuilder
599
     */
600
    public function setPrice(float $price): AppBuilder
601
    {
602
        $this->price = $price;
603
        return $this;
604
    }
605
606
    /**
607
     * @return string|null
608
     */
609
    public function getCurrency(): ?string
610
    {
611
        return $this->currency;
612
    }
613
614
    /**
615
     * @param string|null $currency
616
     * @return AppBuilder
617
     */
618
    public function setCurrency(?string $currency): AppBuilder
619
    {
620
        $this->currency = $currency;
621
        return $this;
622
    }
623
624
    /**
625
     * @return string|null
626
     */
627
    public function getOffersIAPCost(): ?string
628
    {
629
        return $this->offersIAPCost;
630
    }
631
632
    /**
633
     * @param string|null $offersIAPCost
634
     * @return AppBuilder
635
     */
636
    public function setOffersIAPCost(?string $offersIAPCost): AppBuilder
637
    {
638
        $this->offersIAPCost = $offersIAPCost;
639
        return $this;
640
    }
641
642
    /**
643
     * @return bool
644
     */
645
    public function isAdSupported(): bool
646
    {
647
        return $this->adSupported;
648
    }
649
650
    /**
651
     * @param bool $adSupported
652
     * @return AppBuilder
653
     */
654
    public function setAdSupported(bool $adSupported): AppBuilder
655
    {
656
        $this->adSupported = $adSupported;
657
        return $this;
658
    }
659
660
    /**
661
     * @return string|null
662
     */
663
    public function getAppSize(): ?string
664
    {
665
        return $this->appSize;
666
    }
667
668
    /**
669
     * @param string|null $appSize
670
     * @return AppBuilder
671
     */
672
    public function setAppSize(?string $appSize): AppBuilder
673
    {
674
        $this->appSize = $appSize;
675
        return $this;
676
    }
677
678
    /**
679
     * @return string|null
680
     */
681
    public function getAppVersion(): ?string
682
    {
683
        return $this->appVersion;
684
    }
685
686
    /**
687
     * @param string|null $appVersion
688
     * @return AppBuilder
689
     */
690
    public function setAppVersion(?string $appVersion): AppBuilder
691
    {
692
        $this->appVersion = $appVersion;
693
        return $this;
694
    }
695
696
    /**
697
     * @return string|null
698
     */
699
    public function getAndroidVersion(): ?string
700
    {
701
        return $this->androidVersion;
702
    }
703
704
    /**
705
     * @param string|null $androidVersion
706
     * @return AppBuilder
707
     */
708
    public function setAndroidVersion(?string $androidVersion): AppBuilder
709
    {
710
        $this->androidVersion = $androidVersion;
711
        return $this;
712
    }
713
714
    /**
715
     * @return string|null
716
     */
717
    public function getMinAndroidVersion(): ?string
718
    {
719
        return $this->minAndroidVersion;
720
    }
721
722
    /**
723
     * @param string|null $minAndroidVersion
724
     * @return AppBuilder
725
     */
726
    public function setMinAndroidVersion(?string $minAndroidVersion): AppBuilder
727
    {
728
        $this->minAndroidVersion = $minAndroidVersion;
729
        return $this;
730
    }
731
732
    /**
733
     * @return string|null
734
     */
735
    public function getContentRating(): ?string
736
    {
737
        return $this->contentRating;
738
    }
739
740
    /**
741
     * @param string|null $contentRating
742
     * @return AppBuilder
743
     */
744
    public function setContentRating(?string $contentRating): AppBuilder
745
    {
746
        $this->contentRating = $contentRating;
747
        return $this;
748
    }
749
750
    /**
751
     * @return \DateTimeInterface|null
752
     */
753
    public function getReleased(): ?\DateTimeInterface
754
    {
755
        return $this->released;
756
    }
757
758
    /**
759
     * @param \DateTimeInterface|null $released
760
     * @return AppBuilder
761
     */
762
    public function setReleased(?\DateTimeInterface $released): AppBuilder
763
    {
764
        $this->released = $released;
765
        return $this;
766
    }
767
768
    /**
769
     * @return \DateTimeInterface|null
770
     */
771
    public function getUpdated(): ?\DateTimeInterface
772
    {
773
        return $this->updated;
774
    }
775
776
    /**
777
     * @param \DateTimeInterface|null $updated
778
     * @return AppBuilder
779
     */
780
    public function setUpdated(?\DateTimeInterface $updated): AppBuilder
781
    {
782
        $this->updated = $updated;
783
        return $this;
784
    }
785
786
    /**
787
     * @return int
788
     */
789
    public function getReviewsCount(): int
790
    {
791
        return $this->reviewsCount;
792
    }
793
794
    /**
795
     * @param int $reviewsCount
796
     * @return AppBuilder
797
     */
798
    public function setReviewsCount(int $reviewsCount): AppBuilder
799
    {
800
        $this->reviewsCount = $reviewsCount;
801
        return $this;
802
    }
803
804
    /**
805
     * @return Review[]
806
     */
807
    public function getReviews(): array
808
    {
809
        return $this->reviews;
810
    }
811
812
    /**
813
     * @param Review[] $reviews
814
     * @return AppBuilder
815
     */
816
    public function setReviews(array $reviews): AppBuilder
817
    {
818
        $this->reviews = [];
819
        foreach ($reviews as $review) {
820
            $this->addReview($review);
821
        }
822
        return $this;
823
    }
824
825
    /**
826
     * @param Review $review
827
     * @return AppBuilder
828
     */
829
    public function addReview(Review $review): AppBuilder
830
    {
831
        $this->reviews[] = $review;
832
        return $this;
833
    }
834
}
835