Passed
Push — 1.x-dev ( 8f914b...081a6e )
by Doug
04:31
created

WorkingVolume::getEmptyWeight()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * Box packing (3D bin packing, knapsack problem).
4
 *
5
 * @author Doug Wright
6
 */
7
namespace DVDoug\BoxPacker;
8
9
use JsonSerializable;
10
11
/**
12
 * Class WorkingVolume.
13
 * @internal
14
 */
15
class WorkingVolume implements Box, JsonSerializable
16
{
17
    /**
18
     * @var int
19
     */
20
    private $width;
21
22
    /**
23
     * @var int
24
     */
25
    private $length;
26
27
    /**
28
     * @var int
29
     */
30
    private $depth;
31
32
    /**
33
     * @var int
34
     */
35
    private $maxWeight;
36
37
    /**
38
     * Constructor.
39
     *
40
     * @param int $width
41
     * @param int $length
42
     * @param int $depth
43
     * @param int $maxWeight
44
     */
45 2
    public function __construct(
46
        $width,
47
        $length,
48
        $depth,
49
        $maxWeight
50
    ) {
51 2
        $this->width = $width;
52 2
        $this->length = $length;
53 2
        $this->depth = $depth;
54 2
        $this->maxWeight = $maxWeight;
55 2
    }
56
57
    /**
58
     * @return string
59
     */
60 2
    public function getReference()
61
    {
62 2
        return 'Working Volume';
63
    }
64
65
    /**
66
     * @return int
67
     */
68
    public function getOuterWidth()
69
    {
70
        return $this->width;
71
    }
72
73
    /**
74
     * @return int
75
     */
76
    public function getOuterLength()
77
    {
78
        return $this->length;
79
    }
80
81
    /**
82
     * @return int
83
     */
84
    public function getOuterDepth()
85
    {
86
        return $this->depth;
87
    }
88
89
    /**
90
     * @return int
91
     */
92 2
    public function getEmptyWeight()
93
    {
94 2
        return 0;
95
    }
96
97
    /**
98
     * @return int
99
     */
100 2
    public function getInnerWidth()
101
    {
102 2
        return $this->width;
103
    }
104
105
    /**
106
     * @return int
107
     */
108 2
    public function getInnerLength()
109
    {
110 2
        return $this->length;
111
    }
112
113
    /**
114
     * @return int
115
     */
116 2
    public function getInnerDepth()
117
    {
118 2
        return $this->depth;
119
    }
120
121
    /**
122
     * @return int
123
     */
124 2
    public function getMaxWeight()
125
    {
126 2
        return $this->maxWeight;
127
    }
128
129
    /**
130
     * @return int
131
     */
132
    public function getInnerVolume()
133
    {
134
        return $this->width * $this->length * $this->depth;
135
    }
136
137
    /**
138
     * {@inheritdoc}
139
     */
140
    public function jsonSerialize()
141
    {
142
        return [
143
            'reference' => $this->getReference(),
144
            'width' => $this->width,
145
            'length' => $this->length,
146
            'depth' => $this->depth,
147
            'maxWeight' => $this->maxWeight,
148
        ];
149
    }
150
}
151