Completed
Push — master ( aac319...996365 )
by Rafal
11s
created

GamePastBetting::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 8

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