Completed
Push — master ( 30874d...ed8031 )
by Pablo
02:56
created

PreCommitResponse::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
ccs 13
cts 13
cp 1
rs 8.8571
cc 1
eloc 23
nc 1
nop 11
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 bool
13
     */
14
    private $rightMessage;
15
    /**
16
     * @var string
17
     */
18
    private $errorMessage;
19
    /**
20
     * @var string
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
    /**
53
     * PreCommitResponse constructor.
54
     *
55
     * @param bool                          $preCommit
56
     * @param string                        $rightMessage
57
     * @param string                        $errorMessage
58
     * @param bool                          $composer
59
     * @param bool                          $jsonLint
60
     * @param bool                          $phpLint
61
     * @param PhpMdResponse                 $phpMd
62
     * @param PhpCsResponse                 $phpCs
63
     * @param PhpCsFixerResponse            $phpCsFixer
64
     * @param PhpUnitResponse               $phpUnit
65
     * @param PhpUnitStrictCoverageResponse $phpUnitStrictCoverage
66
     */
67 10
    public function __construct(
68
        $preCommit,
69
        $rightMessage,
70
        $errorMessage,
71
        $composer,
72
        $jsonLint,
73
        $phpLint,
74
        PhpMdResponse $phpMd,
75
        PhpCsResponse $phpCs,
76
        PhpCsFixerResponse $phpCsFixer,
77
        PhpUnitResponse $phpUnit,
78
        PhpUnitStrictCoverageResponse $phpUnitStrictCoverage
79
    ) {
80 10
        $this->preCommit = $preCommit;
81 10
        $this->rightMessage = $rightMessage;
0 ignored issues
show
Documentation Bug introduced by
The property $rightMessage was declared of type boolean, but $rightMessage is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
82 10
        $this->errorMessage = $errorMessage;
83 10
        $this->composer = $composer;
0 ignored issues
show
Documentation Bug introduced by
The property $composer was declared of type string, but $composer is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
84 10
        $this->jsonLint = $jsonLint;
85 10
        $this->phpLint = $phpLint;
86 10
        $this->phpMd = $phpMd;
87 10
        $this->phpCs = $phpCs;
88 10
        $this->phpCsFixer = $phpCsFixer;
89 10
        $this->phpUnit = $phpUnit;
90 10
        $this->phpUnitStrictCoverage = $phpUnitStrictCoverage;
91 10
    }
92
93
    /**
94
     * @return bool
95
     */
96 2
    public function isPreCommit()
97
    {
98 2
        return $this->preCommit;
99
    }
100
101
    /**
102
     * @return string
103
     */
104 2
    public function getRightMessage()
105
    {
106 2
        return $this->rightMessage;
107
    }
108
109
    /**
110
     * @return string
111
     */
112 5
    public function getErrorMessage()
113
    {
114 5
        return $this->errorMessage;
115
    }
116
117
    /**
118
     * @return bool
119
     */
120 2
    public function isComposer()
121
    {
122 2
        return $this->composer;
123
    }
124
125
    /**
126
     * @return bool
127
     */
128 2
    public function isJsonLint()
129
    {
130 2
        return $this->jsonLint;
131
    }
132
133
    /**
134
     * @return bool
135
     */
136 2
    public function isPhpLint()
137
    {
138 2
        return $this->phpLint;
139
    }
140
141
    /**
142
     * @return PhpMdResponse
143
     */
144 2
    public function getPhpMd()
145
    {
146 2
        return $this->phpMd;
147
    }
148
149
    /**
150
     * @return PhpCsResponse
151
     */
152 2
    public function getPhpCs()
153
    {
154 2
        return $this->phpCs;
155
    }
156
157
    /**
158
     * @return PhpCsFixerResponse
159
     */
160 5
    public function getPhpCsFixer()
161
    {
162 5
        return $this->phpCsFixer;
163
    }
164
165
    /**
166
     * @return PhpUnitResponse
167
     */
168 2
    public function getPhpUnit()
169
    {
170 2
        return $this->phpUnit;
171
    }
172
173
    /**
174
     * @return PhpUnitStrictCoverageResponse
175
     */
176 1
    public function getPhpUnitStrictCoverage()
177
    {
178 1
        return $this->phpUnitStrictCoverage;
179
    }
180
}
181