Completed
Branch develop (45165d)
by Alexey
04:09
created

Review::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

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

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
declare(strict_types=1);
3
4
namespace Nelexa\GPlay\Model;
5
6
class Review
7
{
8
    /**
9
     * @var string
10
     */
11
    private $id;
12
    /**
13
     * @var string
14
     */
15
    private $url;
16
    /**
17
     * @var string
18
     */
19
    private $userName;
20
    /**
21
     * @var string
22
     */
23
    private $text;
24
    /**
25
     * @var GoogleImage
26
     */
27
    private $avatar;
28
    /**
29
     * @var \DateTimeInterface
30
     */
31
    private $date;
32
    /**
33
     * @var int
34
     */
35
    private $score;
36
    /**
37
     * @var int
38
     */
39
    private $likeCount;
40
    /**
41
     * @var ReplyReview|null
42
     */
43
    private $reply;
44
45
    /**
46
     * Review constructor.
47
     *
48
     * @param string $id
49
     * @param string $url
50
     * @param string $userName
51
     * @param string $text
52
     * @param GoogleImage $avatar
53
     * @param \DateTimeInterface $date
54
     * @param int $score
55
     * @param int $likeCount
56
     * @param ReplyReview|null $reply
57
     */
58
    public function __construct(
59
        string $id,
60
        string $url,
61
        string $userName,
62
        string $text,
63
        GoogleImage $avatar,
64
        \DateTimeInterface $date,
65
        int $score,
66
        int $likeCount = 0,
67
        ?ReplyReview $reply = null
68
    ) {
69
        $this->id = $id;
70
        $this->url = $url;
71
        $this->userName = $userName;
72
        $this->text = $text;
73
        $this->avatar = $avatar;
74
        $this->date = $date;
75
        $this->score = $score;
76
        $this->likeCount = $likeCount;
77
        $this->reply = $reply;
78
    }
79
80
    /**
81
     * @return string
82
     */
83
    public function getId(): string
84
    {
85
        return $this->id;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getUrl(): string
92
    {
93
        return $this->url;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getUserName(): string
100
    {
101
        return $this->userName;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function getText(): string
108
    {
109
        return $this->text;
110
    }
111
112
    /**
113
     * @return GoogleImage
114
     */
115
    public function getAvatar(): GoogleImage
116
    {
117
        return $this->avatar;
118
    }
119
120
    /**
121
     * @return \DateTimeInterface
122
     */
123
    public function getDate(): \DateTimeInterface
124
    {
125
        return $this->date;
126
    }
127
128
    /**
129
     * @return int
130
     */
131
    public function getScore(): int
132
    {
133
        return $this->score;
134
    }
135
136
    /**
137
     * @return int
138
     */
139
    public function getLikeCount(): int
140
    {
141
        return $this->likeCount;
142
    }
143
144
    /**
145
     * @return ReplyReview|null
146
     */
147
    public function getReply(): ?ReplyReview
148
    {
149
        return $this->reply;
150
    }
151
}
152