Passed
Push — 3.x ( 97397b...854a27 )
by Doug
12:23 queued 10:33
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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
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
use ReturnTypeWillChange;
13
14
/**
15
 * Class WorkingVolume.
16
 * @internal
17
 */
18
class WorkingVolume implements Box, JsonSerializable
19
{
20
    private int $width;
21
22
    private int $length;
23
24
    private int $depth;
25
26
    private int $maxWeight;
27
28
    /**
29
     * Constructor.
30
     */
31 23
    public function __construct(
32
        int $width,
33
        int $length,
34
        int $depth,
35
        int $maxWeight
36
    ) {
37 23
        $this->width = $width;
38 23
        $this->length = $length;
39 23
        $this->depth = $depth;
40 23
        $this->maxWeight = $maxWeight;
41
    }
42
43 22
    public function getReference(): string
44
    {
45 22
        return "Working Volume {$this->width}x{$this->length}x{$this->depth}";
46
    }
47
48 1
    public function getOuterWidth(): int
49
    {
50 1
        return $this->width;
51
    }
52
53 1
    public function getOuterLength(): int
54
    {
55 1
        return $this->length;
56
    }
57
58 1
    public function getOuterDepth(): int
59
    {
60 1
        return $this->depth;
61
    }
62
63 22
    public function getEmptyWeight(): int
64
    {
65 22
        return 0;
66
    }
67
68 22
    public function getInnerWidth(): int
69
    {
70 22
        return $this->width;
71
    }
72
73 22
    public function getInnerLength(): int
74
    {
75 22
        return $this->length;
76
    }
77
78 22
    public function getInnerDepth(): int
79
    {
80 22
        return $this->depth;
81
    }
82
83 22
    public function getMaxWeight(): int
84
    {
85 22
        return $this->maxWeight;
86
    }
87
88 1
    #[ReturnTypeWillChange]
89
    public function jsonSerialize()/* : mixed */
90
    {
91 1
        return [
92 1
            'reference' => $this->getReference(),
93 1
            'width' => $this->width,
94 1
            'length' => $this->length,
95 1
            'depth' => $this->depth,
96 1
            'maxWeight' => $this->maxWeight,
97 1
        ];
98
    }
99
}
100