Passed
Push — master ( 86b291...5e082c )
by Willy
02:08
created

StandardItemValueObject::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

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 Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Item;
4
5
/**
6
 * @author  Willy Reiche
7
 * @since   2017-08-23
8
 * @version 1.0
9
 */
10
class StandardItemValueObject
11
{
12
    /**
13
     * @var int
14
     */
15
    private $id;
16
    /**
17
     * @var string
18
     */
19
    private $name;
20
    /**
21
     * @var string
22
     */
23
    private $icon;
24
    /**
25
     * @var int
26
     */
27
    private $quality;
28
    /**
29
     * @var int
30
     */
31
    private $itemLevel;
32
    /**
33
     * @var TooltipParamsValueObject
34
     */
35
    private $tooltipParams;
36
    /**
37
     * @var ItemStatValueObject[]
38
     */
39
    private $stats;
40
    /**
41
     * @var int
42
     */
43
    private $armor;
44
    /**
45
     * @var string
46
     */
47
    private $context;
48
    /**
49
     * @var int[]
50
     */
51
    private $bonusLists;
52
    /**
53
     * @var int
54
     */
55
    private $displayInfoId;
56
    /**
57
     * @var ItemAppearanceValueObject
58
     */
59
    private $appearance;
60
61
    /**
62
     * ArmorItemValueObject constructor.
63
     * @param int                       $id
64
     * @param string                    $name
65
     * @param string                    $icon
66
     * @param int                       $quality
67
     * @param int                       $itemLevel
68
     * @param TooltipParamsValueObject  $tooltipParams
69
     * @param ItemStatValueObject[]     $stats
70
     * @param int                       $armor
71
     * @param string                    $context
72
     * @param int[]                     $bonusLists
73
     * @param int                       $displayInfoId
74
     * @param ItemAppearanceValueObject $appearance
75
     */
76
    public function __construct(
77
        $id,
78
        $name,
79
        $icon,
80
        $quality,
81
        $itemLevel,
82
        $tooltipParams,
83
        $stats,
84
        $armor,
85
        $context,
86
        $bonusLists,
87
        $displayInfoId,
88
        $appearance
89
    ) {
90
        $this->id = $id;
91
        $this->name = $name;
92
        $this->icon = $icon;
93
        $this->quality = $quality;
94
        $this->itemLevel = $itemLevel;
95
        $this->tooltipParams = $tooltipParams;
96
        $this->stats = $stats;
97
        $this->armor = $armor;
98
        $this->context = $context;
99
        $this->bonusLists = $bonusLists;
100
        $this->displayInfoId = $displayInfoId;
101
        $this->appearance = $appearance;
102
    }
103
104
    /**
105
     * @return int
106
     */
107
    public function getId()
108
    {
109
        return $this->id;
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    public function getName()
116
    {
117
        return $this->name;
118
    }
119
120
    /**
121
     * @return string
122
     */
123
    public function getIcon()
124
    {
125
        return $this->icon;
126
    }
127
128
    /**
129
     * @return int
130
     */
131
    public function getQuality()
132
    {
133
        return $this->quality;
134
    }
135
136
    /**
137
     * @return int
138
     */
139
    public function getItemLevel()
140
    {
141
        return $this->itemLevel;
142
    }
143
144
    /**
145
     * @return TooltipParamsValueObject
146
     */
147
    public function getTooltipParams()
148
    {
149
        return $this->tooltipParams;
150
    }
151
152
    /**
153
     * @return ItemStatValueObject[]
154
     */
155
    public function getStats()
156
    {
157
        return $this->stats;
158
    }
159
160
    /**
161
     * @return int
162
     */
163
    public function getArmor()
164
    {
165
        return $this->armor;
166
    }
167
168
    /**
169
     * @return string
170
     */
171
    public function getContext()
172
    {
173
        return $this->context;
174
    }
175
176
    /**
177
     * @return int[]
178
     */
179
    public function getBonusLists()
180
    {
181
        return $this->bonusLists;
182
    }
183
184
    /**
185
     * @return int
186
     */
187
    public function getDisplayInfoId()
188
    {
189
        return $this->displayInfoId;
190
    }
191
192
    /**
193
     * @return ItemAppearanceValueObject
194
     */
195
    public function getAppearance()
196
    {
197
        return $this->appearance;
198
    }
199
}
200