Passed
Push — master ( 73ddcb...629397 )
by Doug
02:34
created

WorkingVolume   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 24
c 1
b 0
f 0
dl 0
loc 93
ccs 30
cts 30
cp 1
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getOuterLength() 0 3 1
A __construct() 0 10 1
A getEmptyWeight() 0 3 1
A getInnerDepth() 0 3 1
A getInnerLength() 0 3 1
A getReference() 0 3 1
A jsonSerialize() 0 8 1
A getMaxWeight() 0 3 1
A getOuterWidth() 0 3 1
A getOuterDepth() 0 3 1
A getInnerWidth() 0 3 1
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
    /**
20
     * @var int
21
     */
22
    private $width;
23
24
    /**
25
     * @var int
26
     */
27
    private $length;
28
29
    /**
30
     * @var int
31
     */
32
    private $depth;
33
34
    /**
35
     * @var int
36
     */
37
    private $maxWeight;
38
39
    /**
40
     * Constructor.
41
     */
42 42
    public function __construct(
43
        int $width,
44
        int $length,
45
        int $depth,
46
        int $maxWeight
47
    ) {
48 42
        $this->width = $width;
49 42
        $this->length = $length;
50 42
        $this->depth = $depth;
51 42
        $this->maxWeight = $maxWeight;
52 42
    }
53
54 41
    public function getReference(): string
55
    {
56 41
        return "Working Volume {$this->width}x{$this->length}x{$this->depth}";
57
    }
58
59 1
    public function getOuterWidth(): int
60
    {
61 1
        return $this->width;
62
    }
63
64 1
    public function getOuterLength(): int
65
    {
66 1
        return $this->length;
67
    }
68
69 1
    public function getOuterDepth(): int
70
    {
71 1
        return $this->depth;
72
    }
73
74 41
    public function getEmptyWeight(): int
75
    {
76 41
        return 0;
77
    }
78
79 41
    public function getInnerWidth(): int
80
    {
81 41
        return $this->width;
82
    }
83
84 41
    public function getInnerLength(): int
85
    {
86 41
        return $this->length;
87
    }
88
89 41
    public function getInnerDepth(): int
90
    {
91 41
        return $this->depth;
92
    }
93
94 41
    public function getMaxWeight(): int
95
    {
96 41
        return $this->maxWeight;
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102 1
    public function jsonSerialize(): array
103
    {
104
        return [
105 1
            'reference' => $this->getReference(),
106 1
            'width' => $this->width,
107 1
            'length' => $this->length,
108 1
            'depth' => $this->depth,
109 1
            'maxWeight' => $this->maxWeight,
110
        ];
111
    }
112
}
113