Passed
Push — master ( 39dd2f...8ee4e9 )
by Rafal
03:50
created

GamePastBetting::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 9
dl 0
loc 21
rs 9.584
c 0
b 0
f 0

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
3
4
namespace App\GameBetting\Persistence\DataProvider;
5
6
7
class GamePastBetting
8
{
9
    /**
10
     * @var int
11
     */
12
    private $gameId;
13
14
    /**
15
     * @var string
16
     */
17
    private $firstTeamName;
18
19
    /**
20
     * @var string
21
     */
22
    private $secondTeamName;
23
24
    /**
25
     * @var \DateTimeInterface
26
     */
27
    private $gameDate;
28
29
    /**
30
     * @var int
31
     */
32
    private $firstTeamResult;
33
34
    /**
35
     * @var int
36
     */
37
    private $secondTeamResult;
38
39
    /**
40
     * @var int
41
     */
42
    private $firstTeamUserResult;
43
44
    /**
45
     * @var int
46
     */
47
    private $secondTeamUserResult;
48
49
    /**
50
     * @var int
51
     */
52
    private $score;
53
54
    /**
55
     * @param int $gameId
56
     * @param string $firstTeamName
57
     * @param string $secondTeamName
58
     * @param \DateTimeInterface $gameDate
59
     * @param int|null $firstTeamResult
60
     * @param int|null $secondTeamResult
61
     * @param int|null $firstTeamUserResult
62
     * @param int|null $secondTeamUserResult
63
     * @param int $score
64
     */
65
    public function __construct(
66
        int $gameId,
67
        string $firstTeamName,
68
        string $secondTeamName,
69
        \DateTimeInterface $gameDate,
70
        ?int $firstTeamResult,
71
        ?int $secondTeamResult,
72
        ?int $firstTeamUserResult,
73
        ?int $secondTeamUserResult,
74
        int $score
75
    )
76
    {
77
        $this->gameId = $gameId;
78
        $this->firstTeamName = $firstTeamName;
79
        $this->secondTeamName = $secondTeamName;
80
        $this->gameDate = $gameDate;
81
        $this->firstTeamResult = $firstTeamResult;
82
        $this->secondTeamResult = $secondTeamResult;
83
        $this->firstTeamUserResult = $firstTeamUserResult;
84
        $this->secondTeamUserResult = $secondTeamUserResult;
85
        $this->score = $score;
86
    }
87
88
    /**
89
     * @return int
90
     */
91
    public function getGameId(): int
92
    {
93
        return $this->gameId;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getFirstTeamName(): string
100
    {
101
        return $this->firstTeamName;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function getSecondTeamName(): string
108
    {
109
        return $this->secondTeamName;
110
    }
111
112
    /**
113
     * @return \DateTimeInterface
114
     */
115
    public function getGameDate(): \DateTimeInterface
116
    {
117
        return $this->gameDate;
118
    }
119
120
    /**
121
     * @return int
122
     */
123
    public function getFirstTeamResult(): int
124
    {
125
        return $this->firstTeamResult;
126
    }
127
128
    /**
129
     * @return int
130
     */
131
    public function getSecondTeamResult(): int
132
    {
133
        return $this->secondTeamResult;
134
    }
135
136
    /**
137
     * @return int
138
     */
139
    public function getFirstTeamUserResult(): ?int
140
    {
141
        return $this->firstTeamUserResult;
142
    }
143
144
    /**
145
     * @return int
146
     */
147
    public function getSecondTeamUserResult(): ?int
148
    {
149
        return $this->secondTeamUserResult;
150
    }
151
152
    /**
153
     * @return int
154
     */
155
    public function getScore(): int
156
    {
157
        return $this->score;
158
    }
159
}