Passed
Pull Request — master (#344)
by
unknown
05:27 queued 03:46
created

WorkingVolume::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 2
b 0
f 0
nc 1
nop 4
dl 0
loc 10
ccs 5
cts 5
cp 1
crap 1
rs 10
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
    private int $width;
20
21
    private int $length;
22
23
    private int $depth;
24
25
    private int $maxWeight;
26
27 4
    public function __construct(
28
        int $width,
29
        int $length,
30
        int $depth,
31
        int $maxWeight
32
    ) {
33 4
        $this->width = $width;
34 4
        $this->length = $length;
35 4
        $this->depth = $depth;
36 4
        $this->maxWeight = $maxWeight;
37
    }
38
39 4
    public function getReference(): string
40
    {
41 4
        return "Working Volume {$this->width}x{$this->length}x{$this->depth}";
42
    }
43
44
    public function getOuterWidth(): int
45
    {
46
        return $this->width;
47
    }
48
49
    public function getOuterLength(): int
50
    {
51
        return $this->length;
52
    }
53
54
    public function getOuterDepth(): int
55
    {
56
        return $this->depth;
57
    }
58
59 4
    public function getEmptyWeight(): int
60
    {
61 4
        return 0;
62
    }
63
64 4
    public function getInnerWidth(): int
65
    {
66 4
        return $this->width;
67
    }
68
69 4
    public function getInnerLength(): int
70
    {
71 4
        return $this->length;
72
    }
73
74 4
    public function getInnerDepth(): int
75
    {
76 4
        return $this->depth;
77
    }
78
79 4
    public function getMaxWeight(): int
80
    {
81 4
        return $this->maxWeight;
82
    }
83
84
    public function jsonSerialize(): array
85
    {
86
        return [
87
            'reference' => $this->getReference(),
88
            'width' => $this->width,
89
            'length' => $this->length,
90
            'depth' => $this->depth,
91
            'maxWeight' => $this->maxWeight,
92
        ];
93
    }
94
}
95