Passed
Push — master ( 8de8ac...4e9f9e )
by Doug
05:17 queued 02:42
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 24
    public function __construct(
28
        int $width,
29
        int $length,
30
        int $depth,
31
        int $maxWeight
32
    ) {
33 24
        $this->width = $width;
34 24
        $this->length = $length;
35 24
        $this->depth = $depth;
36 24
        $this->maxWeight = $maxWeight;
37
    }
38
39 23
    public function getReference(): string
40
    {
41 23
        return "Working Volume {$this->width}x{$this->length}x{$this->depth}";
42
    }
43
44 1
    public function getOuterWidth(): int
45
    {
46 1
        return $this->width;
47
    }
48
49 1
    public function getOuterLength(): int
50
    {
51 1
        return $this->length;
52
    }
53
54 1
    public function getOuterDepth(): int
55
    {
56 1
        return $this->depth;
57
    }
58
59 23
    public function getEmptyWeight(): int
60
    {
61 23
        return 0;
62
    }
63
64 23
    public function getInnerWidth(): int
65
    {
66 23
        return $this->width;
67
    }
68
69 23
    public function getInnerLength(): int
70
    {
71 23
        return $this->length;
72
    }
73
74 23
    public function getInnerDepth(): int
75
    {
76 23
        return $this->depth;
77
    }
78
79 23
    public function getMaxWeight(): int
80
    {
81 23
        return $this->maxWeight;
82
    }
83
84 1
    public function jsonSerialize(): array
85
    {
86
        return [
87 1
            'reference' => $this->getReference(),
88 1
            'width' => $this->width,
89 1
            'length' => $this->length,
90 1
            'depth' => $this->depth,
91 1
            'maxWeight' => $this->maxWeight,
92
        ];
93
    }
94
}
95