Completed
Push — 2.x-dev ( 5f5b4d...48a1b4 )
by Doug
61:10 queued 51:42
created

TestBox::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 22
rs 9.2
c 1
b 0
f 0
cc 1
eloc 20
nc 1
nop 9

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
 * Box packing (3D bin packing, knapsack problem).
4
 *
5
 * @author Doug Wright
6
 */
7
8
namespace DVDoug\BoxPacker\Test;
9
10
use DVDoug\BoxPacker\Box;
11
12
class TestBox implements Box
13
{
14
    /**
15
     * @var string
16
     */
17
    private $reference;
18
19
    /**
20
     * @var int
21
     */
22
    private $outerWidth;
23
24
    /**
25
     * @var int
26
     */
27
    private $outerLength;
28
29
    /**
30
     * @var int
31
     */
32
    private $outerDepth;
33
34
    /**
35
     * @var int
36
     */
37
    private $emptyWeight;
38
39
    /**
40
     * @var int
41
     */
42
    private $innerWidth;
43
44
    /**
45
     * @var int
46
     */
47
    private $innerLength;
48
49
    /**
50
     * @var int
51
     */
52
    private $innerDepth;
53
54
    /**
55
     * @var int
56
     */
57
    private $maxWeight;
58
59
    /**
60
     * @var int
61
     */
62
    private $innerVolume;
63
64
    /**
65
     * TestBox constructor.
66
     *
67
     * @param string $reference
68
     * @param int    $outerWidth
69
     * @param int    $outerLength
70
     * @param int    $outerDepth
71
     * @param int    $emptyWeight
72
     * @param int    $innerWidth
73
     * @param int    $innerLength
74
     * @param int    $innerDepth
75
     * @param int    $maxWeight
76
     */
77
    public function __construct(
78
        $reference,
79
        $outerWidth,
80
        $outerLength,
81
        $outerDepth,
82
        $emptyWeight,
83
        $innerWidth,
84
        $innerLength,
85
        $innerDepth,
86
        $maxWeight
87
    ) {
88
        $this->reference = $reference;
89
        $this->outerWidth = $outerWidth;
90
        $this->outerLength = $outerLength;
91
        $this->outerDepth = $outerDepth;
92
        $this->emptyWeight = $emptyWeight;
93
        $this->innerWidth = $innerWidth;
94
        $this->innerLength = $innerLength;
95
        $this->innerDepth = $innerDepth;
96
        $this->maxWeight = $maxWeight;
97
        $this->innerVolume = $this->innerWidth * $this->innerLength * $this->innerDepth;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getReference()
104
    {
105
        return $this->reference;
106
    }
107
108
    /**
109
     * @return int
110
     */
111
    public function getOuterWidth()
112
    {
113
        return $this->outerWidth;
114
    }
115
116
    /**
117
     * @return int
118
     */
119
    public function getOuterLength()
120
    {
121
        return $this->outerLength;
122
    }
123
124
    /**
125
     * @return int
126
     */
127
    public function getOuterDepth()
128
    {
129
        return $this->outerDepth;
130
    }
131
132
    /**
133
     * @return int
134
     */
135
    public function getEmptyWeight()
136
    {
137
        return $this->emptyWeight;
138
    }
139
140
    /**
141
     * @return int
142
     */
143
    public function getInnerWidth()
144
    {
145
        return $this->innerWidth;
146
    }
147
148
    /**
149
     * @return int
150
     */
151
    public function getInnerLength()
152
    {
153
        return $this->innerLength;
154
    }
155
156
    /**
157
     * @return int
158
     */
159
    public function getInnerDepth()
160
    {
161
        return $this->innerDepth;
162
    }
163
164
    /**
165
     * @return int
166
     */
167
    public function getInnerVolume()
168
    {
169
        return $this->innerVolume;
170
    }
171
172
    /**
173
     * @return int
174
     */
175
    public function getMaxWeight()
176
    {
177
        return $this->maxWeight;
178
    }
179
}
180