Completed
Pull Request — feature/unmaneged-properties (#20)
by Yo
03:02 queued 17s
created

Configuration::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 19
cts 19
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 34
nc 1
nop 16
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
    /** @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 12
    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 12
        $this->packageName = $packageName;
76 12
        $this->type = $type;
77 12
        $this->description = $description;
78 12
        $this->license = $license;
79 12
        $this->packageVersion = $packageVersion;
80
81 12
        $this->keywordList = $keywordList;
82 12
        $this->authorList = $authorList;
83 12
        $this->providedPackageList = $providedPackageList;
84 12
        $this->suggestedPackageList = $suggestedPackageList;
85 12
        $this->supportList = $supportList;
86 12
        $this->autoloadList = $autoloadList;
87 12
        $this->autoloadDevList = $autoloadDevList;
88 12
        $this->requiredPackageList = $requiredPackageList;
89 12
        $this->requiredPackageList = $requiredPackageList;
90 12
        $this->requiredDevPackageList = $requiredDevPackageList;
91 12
        $this->scriptList = $scriptList;
92 12
        $this->unmanagedPropertyList = $unmanagedPropertyList;
93 12
    }
94
95
    /**
96
     * @return string
97
     */
98 4
    public function getPackageName()
99
    {
100 4
        return $this->packageName;
101
    }
102
103
    /**
104
     * @return string
105
     */
106 4
    public function getType()
107
    {
108 4
        return $this->type;
109
    }
110
111
    /**
112
     * @return string
113
     */
114 4
    public function getLicense()
115
    {
116 4
        return $this->license;
117
    }
118
119
    /**
120
     * @return string
121
     */
122 2
    public function getPackageVersion()
123
    {
124 2
        return $this->packageVersion;
125
    }
126
127
    /**
128
     * @return string
129
     */
130 4
    public function getDescription()
131
    {
132 4
        return $this->description;
133
    }
134
135
    /**
136
     * @return string[]
137
     */
138 4
    public function getKeywordList()
139
    {
140 4
        return $this->keywordList;
141
    }
142
143
    /**
144
     * @return Author[]
145
     */
146 4
    public function getAuthorList()
147
    {
148 4
        return $this->authorList;
149
    }
150
151
    /**
152
     * @return Package[]
153
     */
154 5
    public function getProvidedPackageList()
155
    {
156 5
        return $this->providedPackageList;
157
    }
158
159
    /**
160
     * @return SuggestedPackage[]
161
     */
162 5
    public function getSuggestedPackageList()
163
    {
164 5
        return $this->suggestedPackageList;
165
    }
166
167
    /**
168
     * @return Support[]
169
     */
170 5
    public function getSupportList()
171
    {
172 5
        return $this->supportList;
173
    }
174
175
    /**
176
     * @return Autoload[]
177
     */
178 5
    public function getAutoloadList()
179
    {
180 5
        return $this->autoloadList;
181
    }
182
183
    /**
184
     * @return Autoload[]
185
     */
186 5
    public function getAutoloadDevList()
187
    {
188 5
        return $this->autoloadDevList;
189
    }
190
191
    /**
192
     * @return Package[]
193
     */
194 5
    public function getRequiredPackageList()
195
    {
196 5
        return $this->requiredPackageList;
197
    }
198
199
    /**
200
     * @return Package[]
201
     */
202 5
    public function getRequiredDevPackageList()
203
    {
204 5
        return $this->requiredDevPackageList;
205
    }
206
207
    /**
208
     * @return Script[]
209
     */
210 5
    public function getScriptList()
211
    {
212 5
        return $this->scriptList;
213
    }
214
215
    /**
216
     * @return array
217
     */
218 2
    public function getUnmanagedPropertyList()
219
    {
220 2
        return $this->unmanagedPropertyList;
221
    }
222
}
223