|
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; |
|
15
|
|
|
|
|
16
|
|
|
use Nelexa\GPlay\GPlayApps; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Contains application rating data as data for histogram creation. |
|
20
|
|
|
* |
|
21
|
|
|
* @see GPlayApps::getAppsInfo() Returns detailed information about |
|
22
|
|
|
* many android packages. |
|
23
|
|
|
* @see GPlayApps::getAppInLocales() Returns detailed information |
|
24
|
|
|
* about an application from the Google Play store for an array of locales. |
|
25
|
|
|
* @see GPlayApps::getAppInfoForAvailableLocales() Returns detailed |
|
26
|
|
|
* information about the application in all available locales. |
|
27
|
|
|
*/ |
|
28
|
|
|
class HistogramRating implements \JsonSerializable |
|
29
|
|
|
{ |
|
30
|
|
|
use JsonSerializableTrait; |
|
31
|
|
|
|
|
32
|
|
|
/** @var int Five star app rating. */ |
|
33
|
|
|
private $fiveStars; |
|
34
|
|
|
|
|
35
|
|
|
/** @var int Four star app rating. */ |
|
36
|
|
|
private $fourStars; |
|
37
|
|
|
|
|
38
|
|
|
/** @var int Three star app rating. */ |
|
39
|
|
|
private $threeStars; |
|
40
|
|
|
|
|
41
|
|
|
/** @var int Two star app rating. */ |
|
42
|
|
|
private $twoStars; |
|
43
|
|
|
|
|
44
|
|
|
/** @var int One star app rating. */ |
|
45
|
|
|
private $oneStar; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Creates an object with information about the rating of |
|
49
|
|
|
* Android applications from the Google Play store. |
|
50
|
|
|
* |
|
51
|
|
|
* @param int $fiveStars five star app rating |
|
52
|
|
|
* @param int $fourStars four star app rating |
|
53
|
|
|
* @param int $threeStars three star app rating |
|
54
|
|
|
* @param int $twoStars two star app rating |
|
55
|
|
|
* @param int $oneStar one star app rating |
|
56
|
|
|
*/ |
|
57
|
10 |
|
public function __construct(int $fiveStars, int $fourStars, int $threeStars, int $twoStars, int $oneStar) |
|
58
|
|
|
{ |
|
59
|
10 |
|
$this->fiveStars = $fiveStars; |
|
60
|
10 |
|
$this->fourStars = $fourStars; |
|
61
|
10 |
|
$this->threeStars = $threeStars; |
|
62
|
10 |
|
$this->twoStars = $twoStars; |
|
63
|
10 |
|
$this->oneStar = $oneStar; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Returns the five-star rating of the application. |
|
68
|
|
|
* |
|
69
|
|
|
* @return int five star rating app |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getFiveStars(): int |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->fiveStars; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Returns the four-star rating of the application. |
|
78
|
|
|
* |
|
79
|
|
|
* @return int four star rating app |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getFourStars(): int |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->fourStars; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Returns the three-star rating of the application. |
|
88
|
|
|
* |
|
89
|
|
|
* @return int three star rating app |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getThreeStars(): int |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->threeStars; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Returns the two-star rating of the application. |
|
98
|
|
|
* |
|
99
|
|
|
* @return int two star rating app |
|
100
|
|
|
*/ |
|
101
|
|
|
public function getTwoStars(): int |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->twoStars; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Returns the one-star rating of the application. |
|
108
|
|
|
* |
|
109
|
|
|
* @return int one star rating app |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getOneStar(): int |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->oneStar; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Returns class properties as an array. |
|
118
|
|
|
* |
|
119
|
|
|
* @return array Сlass properties as an array |
|
120
|
|
|
*/ |
|
121
|
|
|
public function asArray(): array |
|
122
|
|
|
{ |
|
123
|
|
|
return [ |
|
124
|
|
|
'five' => $this->fiveStars, |
|
125
|
|
|
'four' => $this->fiveStars, |
|
126
|
|
|
'three' => $this->threeStars, |
|
127
|
|
|
'two' => $this->twoStars, |
|
128
|
|
|
'one' => $this->oneStar, |
|
129
|
|
|
]; |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|