Passed
Push — master ( 80b57f...2460a5 )
by Yo
02:49
created

Configuration::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 18
cts 18
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 32
nc 1
nop 15
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
namespace Yoanm\ComposerConfigManager\Domain\Model;
3
4
class Configuration
5
{
6
    const DEFAULT_TYPE = 'library';
7
    const DEFAULT_LICENSE = 'MIT';
8
    const DEFAULT_VERSION = '0.0.1';
9
10
    /** @var string */
11
    private $packageName;
12
    /** @var string */
13
    private $type;
14
    /** @var string */
15
    private $license;
16
    /** @var string */
17
    private $packageVersion;
18
    /** @var string */
19
    private $description;
20
    /** @var string[] */
21
    private $keywordList = [];
22
    /** @var Author[] */
23
    private $authorList = [];
24
    /** @var Package[] */
25
    private $providedPackageList = [];
26
    /** @var SuggestedPackage[] */
27
    private $suggestedPackageList = [];
28
    /** @var Support[] */
29
    private $supportList = [];
30
    /** @var Autoload[] */
31
    private $autoloadList = [];
32
    /** @var Autoload[] */
33
    private $autoloadDevList = [];
34
    /** @var Package[] */
35
    private $requiredPackageList = [];
36
    /** @var Package[] */
37
    private $requiredDevPackageList = [];
38
    /** @var Script[] */
39
    private $scriptList = [];
40
41
    /**
42
     * @param string      $packageName
43
     * @param string      $type
44
     * @param string      $license
45
     * @param string      $packageVersion
46
     * @param string|null $description
47
     * @param array       $keywordList
48
     * @param array       $authorList
49
     * @param array       $providedPackageList
50
     * @param array       $suggestedPackageList
51
     * @param array       $supportList
52
     * @param array       $autoloadList
53
     * @param array       $autoloadDevList
54
     * @param array       $requiredPackageList
55
     * @param array       $requiredDevPackageList
56
     * @param array       $scriptList
57
     */
58 9
    public function __construct(
59
        $packageName,
60
        $type,
61
        $license,
62
        $packageVersion,
63
        $description,
64
        array $keywordList,
65
        array $authorList,
66
        array $providedPackageList,
67
        array $suggestedPackageList,
68
        array $supportList,
69
        array $autoloadList,
70
        array $autoloadDevList,
71
        array $requiredPackageList,
72
        array $requiredDevPackageList,
73
        array $scriptList
74
    ) {
75 9
        $this->packageName = $packageName;
76 9
        $this->type = $type;
77 9
        $this->description = $description;
78 9
        $this->license = $license;
79 9
        $this->packageVersion = $packageVersion;
80
81 9
        $this->keywordList = $keywordList;
82 9
        $this->authorList = $authorList;
83 9
        $this->providedPackageList = $providedPackageList;
84 9
        $this->suggestedPackageList = $suggestedPackageList;
85 9
        $this->supportList = $supportList;
86 9
        $this->autoloadList = $autoloadList;
87 9
        $this->autoloadDevList = $autoloadDevList;
88 9
        $this->requiredPackageList = $requiredPackageList;
89 9
        $this->requiredPackageList = $requiredPackageList;
90 9
        $this->requiredDevPackageList = $requiredDevPackageList;
91 9
        $this->scriptList = $scriptList;
92 9
    }
93
94
    /**
95
     * @return string
96
     */
97 1
    public function getPackageName()
98
    {
99 1
        return $this->packageName;
100
    }
101
102
    /**
103
     * @return string
104
     */
105 1
    public function getType()
106
    {
107 1
        return $this->type;
108
    }
109
110
    /**
111
     * @return string
112
     */
113 1
    public function getLicense()
114
    {
115 1
        return $this->license;
116
    }
117
118
    /**
119
     * @return string
120
     */
121 1
    public function getPackageVersion()
122
    {
123 1
        return $this->packageVersion;
124
    }
125
126
    /**
127
     * @return string
128
     */
129 1
    public function getDescription()
130
    {
131 1
        return $this->description;
132
    }
133
134
    /**
135
     * @return string[]
136
     */
137 1
    public function getKeywordList()
138
    {
139 1
        return $this->keywordList;
140
    }
141
142
    /**
143
     * @return Author[]
144
     */
145 1
    public function getAuthorList()
146
    {
147 1
        return $this->authorList;
148
    }
149
150
    /**
151
     * @return Package[]
152
     */
153 2
    public function getProvidedPackageList()
154
    {
155 2
        return $this->providedPackageList;
156
    }
157
158
    /**
159
     * @return SuggestedPackage[]
160
     */
161 2
    public function getSuggestedPackageList()
162
    {
163 2
        return $this->suggestedPackageList;
164
    }
165
166
    /**
167
     * @return Support[]
168
     */
169 2
    public function getSupportList()
170
    {
171 2
        return $this->supportList;
172
    }
173
174
    /**
175
     * @return Autoload[]
176
     */
177 2
    public function getAutoloadList()
178
    {
179 2
        return $this->autoloadList;
180
    }
181
182
    /**
183
     * @return Autoload[]
184
     */
185 2
    public function getAutoloadDevList()
186
    {
187 2
        return $this->autoloadDevList;
188
    }
189
190
    /**
191
     * @return Package[]
192
     */
193 2
    public function getRequiredPackageList()
194
    {
195 2
        return $this->requiredPackageList;
196
    }
197
198
    /**
199
     * @return Package[]
200
     */
201 2
    public function getRequiredDevPackageList()
202
    {
203 2
        return $this->requiredDevPackageList;
204
    }
205
206
    /**
207
     * @return Script[]
208
     */
209 2
    public function getScriptList()
210
    {
211 2
        return $this->scriptList;
212
    }
213
}
214