AppBuilder::isContainsAds()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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