Configuration::__construct()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 34
nc 1
nop 16

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