Passed
Push — 3.x ( 05eab4...5fb647 )
by Doug
05:29 queued 03:46
created

WorkingVolume::getReference()   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
declare(strict_types=1);
8
9
namespace DVDoug\BoxPacker;
10
11
use JsonSerializable;
12
use ReturnTypeWillChange;
13
14
/**
15
 * Class WorkingVolume.
16
 * @internal
17
 */
18
class WorkingVolume implements Box, JsonSerializable
19
{
20
    /**
21
     * @var int
22
     */
23
    private $width;
24
25
    /**
26
     * @var int
27
     */
28
    private $length;
29
30
    /**
31
     * @var int
32
     */
33
    private $depth;
34
35
    /**
36
     * @var int
37
     */
38
    private $maxWeight;
39
40
    /**
41
     * Constructor.
42
     */
43 4
    public function __construct(
44
        int $width,
45
        int $length,
46
        int $depth,
47
        int $maxWeight
48
    ) {
49 4
        $this->width = $width;
50 4
        $this->length = $length;
51 4
        $this->depth = $depth;
52 4
        $this->maxWeight = $maxWeight;
53 4
    }
54
55 4
    public function getReference(): string
56
    {
57 4
        return "Working Volume {$this->width}x{$this->length}x{$this->depth}";
58
    }
59
60
    public function getOuterWidth(): int
61
    {
62
        return $this->width;
63
    }
64
65
    public function getOuterLength(): int
66
    {
67
        return $this->length;
68
    }
69
70
    public function getOuterDepth(): int
71
    {
72
        return $this->depth;
73
    }
74
75 4
    public function getEmptyWeight(): int
76
    {
77 4
        return 0;
78
    }
79
80 4
    public function getInnerWidth(): int
81
    {
82 4
        return $this->width;
83
    }
84
85 4
    public function getInnerLength(): int
86
    {
87 4
        return $this->length;
88
    }
89
90 4
    public function getInnerDepth(): int
91
    {
92 4
        return $this->depth;
93
    }
94
95 4
    public function getMaxWeight(): int
96
    {
97 4
        return $this->maxWeight;
98
    }
99
100
    #[ReturnTypeWillChange]
101
    public function jsonSerialize()/*: mixed*/
102
    {
103
        return [
104
            'reference' => $this->getReference(),
105
            'width' => $this->width,
106
            'length' => $this->length,
107
            'depth' => $this->depth,
108
            'maxWeight' => $this->maxWeight,
109
        ];
110
    }
111
}
112