Passed
Push — master ( 458136...010310 )
by Willy
01:57
created

AchievementValueObject::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 19

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 21
ccs 0
cts 21
cp 0
rs 9.3142
cc 1
eloc 19
nc 1
nop 9
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\Model;
4
5
use Kubinashi\BattlenetApi\WorldOfWarcraft\Shared\Criteria\Model\CriteriaValueObject;
6
7
/**
8
 * @author  Willy Reiche
9
 * @since   2017-08-22
10
 * @version 1.0
11
 */
12
class AchievementValueObject
13
{
14
    /**
15
     * @var int
16
     */
17
    private $id;
18
19
    /**
20
     * @var string
21
     */
22
    private $title;
23
24
    /**
25
     * @var int
26
     */
27
    private $points;
28
29
    /**
30
     * @var string
31
     */
32
    private $description;
33
34
    /**
35
     * @var string[]
36
     */
37
    private $rewardItems;
38
39
    /**
40
     * @var string
41
     */
42
    private $icon;
43
44
    /**
45
     * @var CriteriaValueObject[]
46
     */
47
    private $criteria;
48
49
    /**
50
     * @var bool
51
     */
52
    private $accountWide;
53
54
    /**
55
     * @var int
56
     */
57
    private $factionId;
58
59
    /**
60
     * AchievementValueObject constructor.
61
     * @param int                   $id
62
     * @param string                $title
63
     * @param int                   $points
64
     * @param string                $description
65
     * @param string[]              $rewardItems
66
     * @param string                $icon
67
     * @param CriteriaValueObject[] $criteria
68
     * @param bool                  $accountWide
69
     * @param int                   $factionId
70
     */
71
    public function __construct(
72
        $id,
73
        $title,
74
        $points,
75
        $description,
76
        $rewardItems,
77
        $icon,
78
        $criteria,
79
        $accountWide,
80
        $factionId
81
    ) {
82
        $this->id = $id;
83
        $this->title = $title;
84
        $this->points = $points;
85
        $this->description = $description;
86
        $this->rewardItems = $rewardItems;
87
        $this->icon = $icon;
88
        $this->criteria = $criteria;
89
        $this->accountWide = $accountWide;
90
        $this->factionId = $factionId;
91
    }
92
93
    /**
94
     * @return int
95
     */
96
    public function getId()
97
    {
98
        return $this->id;
99
    }
100
101
    /**
102
     * @return string
103
     */
104
    public function getTitle()
105
    {
106
        return $this->title;
107
    }
108
109
    /**
110
     * @return int
111
     */
112
    public function getPoints()
113
    {
114
        return $this->points;
115
    }
116
117
    /**
118
     * @return string
119
     */
120
    public function getDescription()
121
    {
122
        return $this->description;
123
    }
124
125
    /**
126
     * @return string[]
127
     */
128
    public function getRewardItems()
129
    {
130
        return $this->rewardItems;
131
    }
132
133
    /**
134
     * @return string
135
     */
136
    public function getIcon()
137
    {
138
        return $this->icon;
139
    }
140
141
    /**
142
     * @return CriteriaValueObject[]
143
     */
144
    public function getCriteria()
145
    {
146
        return $this->criteria;
147
    }
148
149
    /**
150
     * @return bool
151
     */
152
    public function isAccountWide()
153
    {
154
        return $this->accountWide;
155
    }
156
157
    /**
158
     * @return int
159
     */
160
    public function getFactionId()
161
    {
162
        return $this->factionId;
163
    }
164
}
165