Completed
Pull Request — master (#85)
by
unknown
02:27
created

PreCommitResponse::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 27
cp 0
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 25
nc 1
nop 12
crap 2

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
namespace PhpGitHooks\Module\Configuration\Contract\Response;
4
5
class PreCommitResponse
6
{
7
    /**
8
     * @var bool
9
     */
10
    private $preCommit;
11
    /**
12
     * @var string
13
     */
14
    private $rightMessage;
15
    /**
16
     * @var string
17
     */
18
    private $errorMessage;
19
    /**
20
     * @var bool
21
     */
22
    private $composer;
23
    /**
24
     * @var bool
25
     */
26
    private $jsonLint;
27
    /**
28
     * @var bool
29
     */
30
    private $phpLint;
31
    /**
32
     * @var PhpMdResponse
33
     */
34
    private $phpMd;
35
    /**
36
     * @var PhpCsResponse
37
     */
38
    private $phpCs;
39
    /**
40
     * @var PhpCsFixerResponse
41
     */
42
    private $phpCsFixer;
43
    /**
44
     * @var PhpUnitResponse
45
     */
46
    private $phpUnit;
47
    /**
48
     * @var PhpUnitStrictCoverageResponse
49
     */
50
    private $phpUnitStrictCoverage;
51
    /**
52
     * @var PhpUnitGuardCoverageResponse
53
     */
54
    private $phpUnitGuardCoverage;
55
56
    /**
57
     * PreCommitResponse constructor.
58
     *
59
     * @param bool                          $preCommit
60
     * @param string                        $rightMessage
61
     * @param string                        $errorMessage
62
     * @param bool                          $composer
63
     * @param bool                          $jsonLint
64
     * @param bool                          $phpLint
65
     * @param PhpMdResponse                 $phpMd
66
     * @param PhpCsResponse                 $phpCs
67
     * @param PhpCsFixerResponse            $phpCsFixer
68
     * @param PhpUnitResponse               $phpUnit
69
     * @param PhpUnitStrictCoverageResponse $phpUnitStrictCoverage
70
     * @param PhpUnitGuardCoverageResponse  $phpUnitGuardCoverage
71
     */
72
    public function __construct(
73
        $preCommit,
74
        $rightMessage,
75
        $errorMessage,
76
        $composer,
77
        $jsonLint,
78
        $phpLint,
79
        PhpMdResponse $phpMd,
80
        PhpCsResponse $phpCs,
81
        PhpCsFixerResponse $phpCsFixer,
82
        PhpUnitResponse $phpUnit,
83
        PhpUnitStrictCoverageResponse $phpUnitStrictCoverage,
84
        PhpUnitGuardCoverageResponse $phpUnitGuardCoverage
85
    ) {
86
        $this->preCommit = $preCommit;
87
        $this->rightMessage = $rightMessage;
88
        $this->errorMessage = $errorMessage;
89
        $this->composer = $composer;
90
        $this->jsonLint = $jsonLint;
91
        $this->phpLint = $phpLint;
92
        $this->phpMd = $phpMd;
93
        $this->phpCs = $phpCs;
94
        $this->phpCsFixer = $phpCsFixer;
95
        $this->phpUnit = $phpUnit;
96
        $this->phpUnitStrictCoverage = $phpUnitStrictCoverage;
97
        $this->phpUnitGuardCoverage = $phpUnitGuardCoverage;
98
    }
99
100
    /**
101
     * @return bool
102
     */
103
    public function isPreCommit()
104
    {
105
        return $this->preCommit;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getRightMessage()
112
    {
113
        return $this->rightMessage;
114
    }
115
116
    /**
117
     * @return string
118
     */
119
    public function getErrorMessage()
120
    {
121
        return $this->errorMessage;
122
    }
123
124
    /**
125
     * @return bool
126
     */
127
    public function isComposer()
128
    {
129
        return $this->composer;
130
    }
131
132
    /**
133
     * @return bool
134
     */
135
    public function isJsonLint()
136
    {
137
        return $this->jsonLint;
138
    }
139
140
    /**
141
     * @return bool
142
     */
143
    public function isPhpLint()
144
    {
145
        return $this->phpLint;
146
    }
147
148
    /**
149
     * @return PhpMdResponse
150
     */
151
    public function getPhpMd()
152
    {
153
        return $this->phpMd;
154
    }
155
156
    /**
157
     * @return PhpCsResponse
158
     */
159
    public function getPhpCs()
160
    {
161
        return $this->phpCs;
162
    }
163
164
    /**
165
     * @return PhpCsFixerResponse
166
     */
167
    public function getPhpCsFixer()
168
    {
169
        return $this->phpCsFixer;
170
    }
171
172
    /**
173
     * @return PhpUnitResponse
174
     */
175
    public function getPhpUnit()
176
    {
177
        return $this->phpUnit;
178
    }
179
180
    /**
181
     * @return PhpUnitStrictCoverageResponse
182
     */
183
    public function getPhpUnitStrictCoverage()
184
    {
185
        return $this->phpUnitStrictCoverage;
186
    }
187
188
    /**
189
     * @return PhpUnitGuardCoverageResponse
190
     */
191
    public function getPhpUnitGuardCoverage()
192
    {
193
        return $this->phpUnitGuardCoverage;
194
    }
195
}
196