WorkingVolume   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 125
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 125
ccs 18
cts 30
cp 0.6
rs 10
c 0
b 0
f 0
wmc 11

11 Methods

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