PreCommitResponse::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 9.488
c 0
b 0
f 0
ccs 14
cts 14
cp 1
cc 1
nc 1
nop 12
crap 1

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 9
    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 9
        $this->preCommit = $preCommit;
87 9
        $this->rightMessage = $rightMessage;
88 9
        $this->errorMessage = $errorMessage;
89 9
        $this->composer = $composer;
90 9
        $this->jsonLint = $jsonLint;
91 9
        $this->phpLint = $phpLint;
92 9
        $this->phpMd = $phpMd;
93 9
        $this->phpCs = $phpCs;
94 9
        $this->phpCsFixer = $phpCsFixer;
95 9
        $this->phpUnit = $phpUnit;
96 9
        $this->phpUnitStrictCoverage = $phpUnitStrictCoverage;
97 9
        $this->phpUnitGuardCoverage = $phpUnitGuardCoverage;
98 9
    }
99
100
    /**
101
     * @return bool
102
     */
103 2
    public function isPreCommit()
104
    {
105 2
        return $this->preCommit;
106
    }
107
108
    /**
109
     * @return string
110
     */
111 2
    public function getRightMessage()
112
    {
113 2
        return $this->rightMessage;
114
    }
115
116
    /**
117
     * @return string
118
     */
119 4
    public function getErrorMessage()
120
    {
121 4
        return $this->errorMessage;
122
    }
123
124
    /**
125
     * @return bool
126
     */
127 2
    public function isComposer()
128
    {
129 2
        return $this->composer;
130
    }
131
132
    /**
133
     * @return bool
134
     */
135 2
    public function isJsonLint()
136
    {
137 2
        return $this->jsonLint;
138
    }
139
140
    /**
141
     * @return bool
142
     */
143 2
    public function isPhpLint()
144
    {
145 2
        return $this->phpLint;
146
    }
147
148
    /**
149
     * @return PhpMdResponse
150
     */
151 2
    public function getPhpMd()
152
    {
153 2
        return $this->phpMd;
154
    }
155
156
    /**
157
     * @return PhpCsResponse
158
     */
159 2
    public function getPhpCs()
160
    {
161 2
        return $this->phpCs;
162
    }
163
164
    /**
165
     * @return PhpCsFixerResponse
166
     */
167 4
    public function getPhpCsFixer()
168
    {
169 4
        return $this->phpCsFixer;
170
    }
171
172
    /**
173
     * @return PhpUnitResponse
174
     */
175 2
    public function getPhpUnit()
176
    {
177 2
        return $this->phpUnit;
178
    }
179
180
    /**
181
     * @return PhpUnitStrictCoverageResponse
182
     */
183 1
    public function getPhpUnitStrictCoverage()
184
    {
185 1
        return $this->phpUnitStrictCoverage;
186
    }
187
188
    /**
189
     * @return PhpUnitGuardCoverageResponse
190
     */
191 3
    public function getPhpUnitGuardCoverage()
192
    {
193 3
        return $this->phpUnitGuardCoverage;
194
    }
195
}
196