Completed
Branch module_structure (3116d9)
by Pablo
02:56
created

ConfigurationDataResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 53
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 27
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 53
rs 9.5797
ccs 27
cts 27
cp 1
cc 1
eloc 51
nc 1
nop 25
crap 1

How to fix   Long Method    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 ConfigurationDataResponse
6
{
7
    /**
8
     * @var bool
9
     */
10
    private $composer;
11
    /**
12
     * @var bool
13
     */
14
    private $jsonLint;
15
    /**
16
     * @var bool
17
     */
18
    private $phpLint;
19
    /**
20
     * @var bool
21
     */
22
    private $phpMd;
23
    /**
24
     * @var bool
25
     */
26
    private $phpCs;
27
    /**
28
     * @var null|string
29
     */
30
    private $phpCsStandard;
31
    /**
32
     * @var bool
33
     */
34
    private $phpCsFixer;
35
    /**
36
     * @var bool
37
     */
38
    private $phpCsFixerPsr0;
39
    /**
40
     * @var bool
41
     */
42
    private $phpCsFixerPsr1;
43
    /**
44
     * @var bool
45
     */
46
    private $phpCsFixerPsr2;
47
    /**
48
     * @var bool
49
     */
50
    private $phpCsFixerSymfony;
51
    /**
52
     * @var bool
53
     */
54
    private $phpunit;
55
    /**
56
     * @var bool
57
     */
58
    private $phpunitRandomMode;
59
    /**
60
     * @var null|string
61
     */
62
    private $phpunitOptions;
63
    /**
64
     * @var bool
65
     */
66
    private $preCommit;
67
    /**
68
     * @var bool
69
     */
70
    private $commitMsg;
71
    /**
72
     * @var null|string
73
     */
74
    private $regularExpression;
75
    /**
76
     * @var null|string
77
     */
78
    private $rightMessage;
79
    /**
80
     * @var null|string
81
     */
82
    private $errorMessage;
83
    /**
84
     * @var bool
85
     */
86
    private $prePush;
87
    /**
88
     * @var bool
89
     */
90
    private $prePushPhpUnit;
91
    /**
92
     * @var bool
93
     */
94
    private $prePushPhpUnitRandom;
95
    /**
96
     * @var null|string
97
     */
98
    private $prePushPhpUnitOptions;
99
    private $prePushRightMessage;
100
    private $prePushErrorMessage;
101
102
    /**
103
     * ConfigurationDataResponse constructor.
104
     *
105
     * @param bool        $preCommit
106
     * @param string|null $rightMessage
107
     * @param string|null $errorMessage
108
     * @param bool        $composer
109
     * @param bool        $jsonLint
110
     * @param bool        $phpLint
111
     * @param bool        $phpMd
112
     * @param bool        $phpCs
113
     * @param string|null $phpCsStandard
114
     * @param bool        $phpCsFixer
115
     * @param bool        $phpCsFixerPsr0
116
     * @param bool        $phpCsFixerPsr1
117
     * @param bool        $phpCsFixerPsr2
118
     * @param bool        $phpCsFixerSymfony
119
     * @param bool        $phpunit
120
     * @param bool        $phpunitRandomMode
121
     * @param string|null $phpunitOptions
122
     * @param bool        $commitMsg
123
     * @param string|null $regularExpression
124
     * @param bool        $prePush
125
     * @param bool        $prePushPhpUnit
126
     * @param bool        $prePushPhpUnitRandom
127
     * @param string|null $prePushPhpUnitOptions
128
     * @param string      $prePushRightMessage
129
     * @param string      $prePushErrorMessage
130
     */
131 10
    public function __construct(
132
        $preCommit,
133
        $rightMessage,
134
        $errorMessage,
135
        $composer,
136
        $jsonLint,
137
        $phpLint,
138
        $phpMd,
139
        $phpCs,
140
        $phpCsStandard,
141
        $phpCsFixer,
142
        $phpCsFixerPsr0,
143
        $phpCsFixerPsr1,
144
        $phpCsFixerPsr2,
145
        $phpCsFixerSymfony,
146
        $phpunit,
147
        $phpunitRandomMode,
148
        $phpunitOptions,
149
        $commitMsg,
150
        $regularExpression,
151
        $prePush,
152
        $prePushPhpUnit,
153
        $prePushPhpUnitRandom,
154
        $prePushPhpUnitOptions,
155
        $prePushRightMessage,
156
        $prePushErrorMessage
157
    ) {
158 10
        $this->composer = $composer;
159 10
        $this->jsonLint = $jsonLint;
160 10
        $this->phpLint = $phpLint;
161 10
        $this->phpMd = $phpMd;
162 10
        $this->phpCs = $phpCs;
163 10
        $this->phpCsStandard = $phpCsStandard;
164 10
        $this->phpCsFixer = $phpCsFixer;
165 10
        $this->phpCsFixerPsr0 = $phpCsFixerPsr0;
166 10
        $this->phpCsFixerPsr1 = $phpCsFixerPsr1;
167 10
        $this->phpCsFixerPsr2 = $phpCsFixerPsr2;
168 10
        $this->phpCsFixerSymfony = $phpCsFixerSymfony;
169 10
        $this->phpunit = $phpunit;
170 10
        $this->phpunitRandomMode = $phpunitRandomMode;
171 10
        $this->phpunitOptions = $phpunitOptions;
172 10
        $this->preCommit = $preCommit;
173 10
        $this->commitMsg = $commitMsg;
174 10
        $this->regularExpression = $regularExpression;
175 10
        $this->rightMessage = $rightMessage;
176 10
        $this->errorMessage = $errorMessage;
177 10
        $this->prePush = $prePush;
178 10
        $this->prePushPhpUnit = $prePushPhpUnit;
179 10
        $this->prePushPhpUnitRandom = $prePushPhpUnitRandom;
180 10
        $this->prePushPhpUnitOptions = $prePushPhpUnitOptions;
181 10
        $this->prePushRightMessage = $prePushRightMessage;
182 10
        $this->prePushErrorMessage = $prePushErrorMessage;
183 10
    }
184
185
    /**
186
     * @return bool
187
     */
188 2
    public function isComposer()
189
    {
190 2
        return $this->composer;
191
    }
192
193
    /**
194
     * @return bool
195
     */
196 2
    public function isJsonLint()
197
    {
198 2
        return $this->jsonLint;
199
    }
200
201
    /**
202
     * @return bool
203
     */
204 2
    public function isPhpLint()
205
    {
206 2
        return $this->phpLint;
207
    }
208
209
    /**
210
     * @return bool
211
     */
212 2
    public function isPhpMd()
213
    {
214 2
        return $this->phpMd;
215
    }
216
217
    /**
218
     * @return null|string
219
     */
220 2
    public function getRightMessage()
221
    {
222 2
        return $this->rightMessage;
223
    }
224
225
    /**
226
     * @return null|string
227
     */
228 5
    public function getErrorMessage()
229
    {
230 5
        return $this->errorMessage;
231
    }
232
233
    /**
234
     * @return bool
235
     */
236 2
    public function isPhpCs()
237
    {
238 2
        return $this->phpCs;
239
    }
240
241
    /**
242
     * @return null|string
243
     */
244 2
    public function getPhpCsStandard()
245
    {
246 2
        return $this->phpCsStandard;
247
    }
248
249
    /**
250
     * @return bool
251
     */
252 2
    public function isPhpCsFixer()
253
    {
254 2
        return $this->phpCsFixer;
255
    }
256
257
    /**
258
     * @return bool
259
     */
260 5
    public function isPhpCsFixerPsr0()
261
    {
262 5
        return $this->phpCsFixerPsr0;
263
    }
264
265
    /**
266
     * @return bool
267
     */
268 5
    public function isPhpCsFixerPsr1()
269
    {
270 5
        return $this->phpCsFixerPsr1;
271
    }
272
273
    /**
274
     * @return bool
275
     */
276 5
    public function isPhpCsFixerPsr2()
277
    {
278 5
        return $this->phpCsFixerPsr2;
279
    }
280
281
    /**
282
     * @return bool
283
     */
284 5
    public function isPhpCsFixerSymfony()
285
    {
286 5
        return $this->phpCsFixerSymfony;
287
    }
288
289
    /**
290
     * @return bool
291
     */
292 2
    public function isPhpunit()
293
    {
294 2
        return $this->phpunit;
295
    }
296
297
    /**
298
     * @return bool
299
     */
300 2
    public function isPhpunitRandomMode()
301
    {
302 2
        return $this->phpunitRandomMode;
303
    }
304
305
    /**
306
     * @return null|string
307
     */
308 2
    public function getPhpunitOptions()
309
    {
310 2
        return $this->phpunitOptions;
311
    }
312
313
    /**
314
     * @return bool
315
     */
316 2
    public function isPreCommit()
317
    {
318 2
        return $this->preCommit;
319
    }
320
321
    /**
322
     * @return bool
323
     */
324 3
    public function isCommitMsg()
325
    {
326 3
        return $this->commitMsg;
327
    }
328
329
    /**
330
     * @return null|string
331
     */
332 1
    public function getRegularExpression()
333
    {
334 1
        return $this->regularExpression;
335
    }
336
337
    /**
338
     * @return bool
339
     */
340 3
    public function isPrePush()
341
    {
342 3
        return $this->prePush;
343
    }
344
345
    /**
346
     * @return bool
347
     */
348 1
    public function isPrePushPhpUnit()
349
    {
350 1
        return $this->prePushPhpUnit;
351
    }
352
353
    /**
354
     * @return bool
355
     */
356 1
    public function isPrePushPhpUnitRandom()
357
    {
358 1
        return $this->prePushPhpUnitRandom;
359
    }
360
361
    /**
362
     * @return null|string
363
     */
364 1
    public function getPrePushPhpUnitOptions()
365
    {
366 1
        return $this->prePushPhpUnitOptions;
367
    }
368
369
    /**
370
     * @return string
371
     */
372 1
    public function getPrePushRightMessage()
373
    {
374 1
        return $this->prePushRightMessage;
375
    }
376
377
    /**
378
     * @return string
379
     */
380 2
    public function getPrePushErrorMessage()
381
    {
382 2
        return $this->prePushErrorMessage;
383
    }
384
}
385