Passed
Branch develop (2fd4b5)
by Alexey
01:46
created

HistogramRating::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0

1 Method

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