Completed
Push — 1.x-dev ( 423a53...2f7d84 )
by Doug
48:23 queued 46:55
created

TestBox::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

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