Passed
Pull Request — master (#549)
by
unknown
15:13 queued 13:32
created

WorkingVolume::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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