Test Failed
Branch develop (c8bc8f)
by Alexey
08:48
created

AppDetail::equals()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
c 0
b 0
f 0
rs 8.9297
cc 6
nc 6
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nelexa\GPlay\Model;
5
6
use Nelexa\GPlay\Model\Builder\AppBuilder;
7
8
class AppDetail extends App
9
{
10
    /**
11
     * @var string
12
     */
13
    private $description;
14
    /**
15
     * @var string|null
16
     */
17
    private $translatedDescription;
18
    /**
19
     * @var string|null
20
     */
21
    private $translatedFromLanguage;
22
    /**
23
     * @var GoogleImage|null
24
     */
25
    private $headerImage;
26
    /**
27
     * @var GoogleImage[]
28
     */
29
    private $screenshots;
30
    /**
31
     * @var Category
32
     */
33
    private $category;
34
    /**
35
     * @var string|null
36
     */
37
    private $privacyPoliceUrl;
38
    /**
39
     * @var Category|null
40
     */
41
    private $categoryFamily;
42
    /**
43
     * @var Video|null
44
     */
45
    private $video;
46
    /**
47
     * @var string|null
48
     */
49
    private $recentChanges;
50
    /**
51
     * @var bool
52
     */
53
    private $editorsChoice;
54
    /**
55
     * @var int
56
     */
57
    private $installs;
58
    /**
59
     * @var int
60
     */
61
    private $numberVoters;
62
    /**
63
     * @var HistogramRating
64
     */
65
    private $histogramRating;
66
    /**
67
     * @var float
68
     */
69
    private $price;
70
    /**
71
     * @var string
72
     */
73
    private $currency;
74
    /**
75
     * Offers in-app purchases
76
     *
77
     * @var string|null
78
     */
79
    private $offersIAPCost;
80
    /**
81
     * @var bool
82
     */
83
    private $adSupported;
84
    /**
85
     * @var string|null
86
     */
87
    private $appSize;
88
    /**
89
     * @var string|null
90
     */
91
    private $appVersion;
92
    /**
93
     * @var string|null
94
     */
95
    private $androidVersion;
96
    /**
97
     * @var string|null
98
     */
99
    private $minAndroidVersion;
100
    /**
101
     * @var string|null
102
     */
103
    private $contentRating;
104
    /**
105
     * @var \DateTimeInterface|null
106
     */
107
    private $released;
108
    /**
109
     * @var \DateTimeInterface|null
110
     */
111
    private $updated;
112
    /**
113
     * @var int
114
     */
115
    private $reviewsCount;
116
    /**
117
     * @var Review[]
118
     */
119
    private $reviews;
120
121
    /**
122
     * AppDetail constructor.
123
     *
124
     * @param AppBuilder $builder
125
     * @throws \InvalidArgumentException
126
     */
127
    public function __construct(AppBuilder $builder)
128
    {
129
        parent::__construct($builder);
130
131
        $this->description = $builder->getDescription();
132
        $this->translatedDescription = $builder->getTranslatedDescription();
133
        $this->translatedFromLanguage = $builder->getTranslatedFromLanguage();
134
        $this->headerImage = $builder->getHeaderImage();
135
        $this->screenshots = $builder->getScreenshots();
136
        $this->category = $builder->getCategory();
137
        $this->categoryFamily = $builder->getCategoryFamily();
138
        $this->privacyPoliceUrl = $builder->getPrivacyPoliceUrl();
139
        $this->video = $builder->getVideo();
140
        $this->recentChanges = $builder->getRecentChanges();
141
        $this->editorsChoice = $builder->isEditorsChoice();
142
        $this->installs = $builder->getInstalls();
143
        $this->numberVoters = $builder->getNumberVoters();
144
        $this->histogramRating = $builder->getHistogramRating() ??
145
            new HistogramRating(0, 0, 0, 0, 0);
146
        $this->price = $builder->getPrice();
147
        $this->currency = $builder->getCurrency() ?? 'USD';
148
        $this->offersIAPCost = $builder->getOffersIAPCost();
149
        $this->adSupported = $builder->isAdSupported();
150
        $this->appSize = $builder->getAppSize();
151
        $this->appVersion = $builder->getAppVersion();
152
        $this->androidVersion = $builder->getAndroidVersion();
153
        $this->minAndroidVersion = $builder->getMinAndroidVersion();
154
        $this->contentRating = $builder->getContentRating();
155
        $this->released = $builder->getReleased();
156
        $this->updated = $builder->getUpdated();
157
        $this->reviewsCount = $builder->getReviewsCount();
158
        $this->reviews = $builder->getReviews();
159
160
        if (empty($this->description)) {
161
            throw new \InvalidArgumentException('$description cannot be null or empty. Solution: $appBuilder->setDescription(...);');
162
        }
163
        if (empty($this->screenshots)) {
164
            throw new \InvalidArgumentException('$screenshots must contain at least one screenshot. Solution: $appBuilder->setScreenshots(...); or $appBuilder->addScreenshot(...);');
165
        }
166
        if ($this->category === null) {
167
            throw new \InvalidArgumentException('$category cannot be null. Solution: $appBuilder->setCategory(...);');
168
        }
169
    }
170
171
    /**
172
     * @return string
173
     */
174
    public function getDescription(): string
175
    {
176
        return $this->description;
177
    }
178
179
    /**
180
     * @return string|null
181
     */
182
    public function getTranslatedDescription(): ?string
183
    {
184
        return $this->translatedDescription;
185
    }
186
187
    /**
188
     * @return string|null
189
     */
190
    public function getTranslatedFromLanguage(): ?string
191
    {
192
        return $this->translatedFromLanguage;
193
    }
194
195
    /**
196
     * @return GoogleImage|null
197
     */
198
    public function getHeaderImage(): ?GoogleImage
199
    {
200
        return $this->headerImage;
201
    }
202
203
    /**
204
     * @return GoogleImage[]
205
     */
206
    public function getScreenshots(): array
207
    {
208
        return $this->screenshots;
209
    }
210
211
    /**
212
     * @return Category
213
     */
214
    public function getCategory(): Category
215
    {
216
        return $this->category;
217
    }
218
219
    /**
220
     * @return string|null
221
     */
222
    public function getPrivacyPoliceUrl(): ?string
223
    {
224
        return $this->privacyPoliceUrl;
225
    }
226
227
    /**
228
     * @return Category|null
229
     */
230
    public function getCategoryFamily(): ?Category
231
    {
232
        return $this->categoryFamily;
233
    }
234
235
    /**
236
     * @return Video|null
237
     */
238
    public function getVideo(): ?Video
239
    {
240
        return $this->video;
241
    }
242
243
    /**
244
     * @return string|null
245
     */
246
    public function getRecentChanges(): ?string
247
    {
248
        return $this->recentChanges;
249
    }
250
251
    /**
252
     * @return bool
253
     */
254
    public function isEditorsChoice(): bool
255
    {
256
        return $this->editorsChoice;
257
    }
258
259
    /**
260
     * @return int
261
     */
262
    public function getInstalls(): int
263
    {
264
        return $this->installs;
265
    }
266
267
    /**
268
     * @return int
269
     */
270
    public function getNumberVoters(): int
271
    {
272
        return $this->numberVoters;
273
    }
274
275
    /**
276
     * @return HistogramRating
277
     */
278
    public function getHistogramRating(): HistogramRating
279
    {
280
        return $this->histogramRating;
281
    }
282
283
    /**
284
     * @return float
285
     */
286
    public function getPrice(): float
287
    {
288
        return $this->price;
289
    }
290
291
    /**
292
     * @return string
293
     */
294
    public function getCurrency(): string
295
    {
296
        return $this->currency;
297
    }
298
299
    /**
300
     * @return bool
301
     */
302
    public function isOffersIAP(): bool
303
    {
304
        return $this->offersIAPCost !== null;
305
    }
306
307
    /**
308
     * @return string|null
309
     */
310
    public function getOffersIAPCost(): ?string
311
    {
312
        return $this->offersIAPCost;
313
    }
314
315
    /**
316
     * @return bool
317
     */
318
    public function isAdSupported(): bool
319
    {
320
        return $this->adSupported;
321
    }
322
323
    /**
324
     * @return string|null
325
     */
326
    public function getAppSize(): ?string
327
    {
328
        return $this->appSize;
329
    }
330
331
    /**
332
     * @return string|null
333
     */
334
    public function getAppVersion(): ?string
335
    {
336
        return $this->appVersion;
337
    }
338
339
    /**
340
     * @return string|null
341
     */
342
    public function getAndroidVersion(): ?string
343
    {
344
        return $this->androidVersion;
345
    }
346
347
    /**
348
     * @return string|null
349
     */
350
    public function getMinAndroidVersion(): ?string
351
    {
352
        return $this->minAndroidVersion;
353
    }
354
355
    /**
356
     * @return string|null
357
     */
358
    public function getContentRating(): ?string
359
    {
360
        return $this->contentRating;
361
    }
362
363
    /**
364
     * @return \DateTimeInterface|null
365
     */
366
    public function getReleased(): ?\DateTimeInterface
367
    {
368
        return $this->released;
369
    }
370
371
    /**
372
     * @return \DateTimeInterface|null
373
     */
374
    public function getUpdated(): ?\DateTimeInterface
375
    {
376
        return $this->updated;
377
    }
378
379
    /**
380
     * @return int
381
     */
382
    public function getReviewsCount(): int
383
    {
384
        return $this->reviewsCount;
385
    }
386
387
    /**
388
     * @return Review[]
389
     */
390
    public function getReviews(): array
391
    {
392
        return $this->reviews;
393
    }
394
395
    /**
396
     * @param AppDetail $o
397
     * @return bool
398
     */
399
    public function equals(AppDetail $o): bool
0 ignored issues
show
Coding Style introduced by
function equals() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
400
    {
401
        if ($o->getId() !== $this->getId()) {
402
            return false;
403
        }
404
        if ($o->getName() !== $this->getName()) {
405
            return false;
406
        }
407
        if ($o->description !== $this->description) {
408
            return false;
409
        }
410
        if ($o->recentChanges !== $this->recentChanges) {
411
            return false;
412
        }
413
        if ($o->getIcon()->getUrl() !== $this->getIcon()->getUrl()) {
414
            return false;
415
        }
416
417
        $diff = array_udiff($o->screenshots, $this->screenshots, static function (GoogleImage $a, GoogleImage $b) {
418
            return strcmp($a->getUrl(), $b->getUrl());
419
        });
420
        return empty($diff);
421
    }
422
}
423