Passed
Push — repack_layers_for_new_height ( e48686 )
by Doug
03:02
created

PackedLayer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 29
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A insert() 0 4 1
A getItems() 0 4 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
/**
12
 * A packed layer
13
 *
14
 * @author Doug Wright
15
 */
16
class PackedLayer
17
{
18
    /**
19
     * Items packed into this layer.
20
     *
21
     * @var PackedItem[]
22
     */
23
    protected $items = [];
24
25
    /**
26
     * Add a packed item to this layer.
27
     *
28
     * @param PackedItem $packedItem
29
     */
30 20
    public function insert(PackedItem $packedItem): void
31
    {
32 20
        $this->items[] = $packedItem;
33 20
    }
34
35
    /**
36
     * Get the packed items
37
     *
38
     * @return PackedItem[]
39
     */
40 20
    public function getItems(): array
41
    {
42 20
        return $this->items;
43
    }
44
}
45