Passed
Branch develop (29ed49)
by Alexey
01:58
created

AppBuilder   F

Complexity

Total Complexity 75

Size/Duplication

Total Lines 805
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 150
dl 0
loc 805
ccs 187
cts 187
cp 1
rs 2.4
c 0
b 0
f 0
wmc 75

73 Methods

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

829
        return new AppId($this->id, $this->locale, /** @scrutinizer ignore-type */ $this->country);
Loading history...
Bug introduced by
It seems like $this->id can also be of type null; however, parameter $id of Nelexa\GPlay\Model\AppId::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

829
        return new AppId(/** @scrutinizer ignore-type */ $this->id, $this->locale, $this->country);
Loading history...
Bug introduced by
It seems like $this->locale can also be of type null; however, parameter $locale of Nelexa\GPlay\Model\AppId::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

829
        return new AppId($this->id, /** @scrutinizer ignore-type */ $this->locale, $this->country);
Loading history...
830
    }
831
}
832