Completed
Push — master ( 9610e0...320eee )
by Doug
08:43
created

PackedItem::getY()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 4
Code Lines 2

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Box packing (3D bin packing, knapsack problem)
4
 * @package BoxPacker
5
 * @author Doug Wright
6
 */
7
namespace DVDoug\BoxPacker;
8
9
/**
10
 * A packed item
11
 * @author Doug Wright
12
 * @package BoxPacker
13
 */
14
class PackedItem
15
{
16
17
    /**
18
     * @var int
19
     */
20
    protected $x;
21
22
    /**
23
     * @var int
24
     */
25
    protected $y;
26
27
    /**
28
     * @var int
29
     */
30
    protected $z;
31
32
    /**
33
     * @var Item
34
     */
35
    protected $item;
36
37
    /**
38
     * @var int
39
     */
40
    protected $width;
41
42
    /**
43
     * @var int
44
     */
45
    protected $length;
46
47
    /**
48
     * @var int
49
     */
50
    protected $depth;
51
52
    /**
53
     * PackedItem constructor.
54
     *
55
     * @param Item $item
56
     * @param int  $x
57
     * @param int  $y
58
     * @param int  $z
59
     * @param int  $width
60
     * @param int  $length
61
     * @param int  $depth
62
     */
63 38
    protected function __construct(Item $item, $x, $y, $z, $width, $length, $depth)
64
    {
65 38
        $this->item = $item;
66 38
        $this->x = $x;
67 38
        $this->y = $y;
68 38
        $this->z = $z;
69 38
        $this->width = $width;
70 38
        $this->length = $length;
71 38
        $this->depth = $depth;
72
    }
73
74
    /**
75
     * @return int
76
     */
77 5
    public function getX()
78
    {
79 5
        return $this->x;
80
    }
81
82
    /**
83
     * @return int
84
     */
85 5
    public function getY()
86
    {
87 5
        return $this->y;
88
    }
89
90
    /**
91
     * @return int
92
     */
93 5
    public function getZ()
94
    {
95 5
        return $this->z;
96
    }
97
98
    /**
99
     * @return Item
100
     */
101 36
    public function getItem()
102
    {
103 36
        return $this->item;
104
    }
105
106
    /**
107
     * @return int
108
     */
109 17
    public function getWidth()
110
    {
111 17
        return $this->width;
112
    }
113
114
    /**
115
     * @return int
116
     */
117 17
    public function getLength()
118
    {
119 17
        return $this->length;
120
    }
121
122
    /**
123
     * @return int
124
     */
125 17
    public function getDepth()
126
    {
127 17
        return $this->depth;
128
    }
129
130
131
    /**
132
     * @param OrientatedItem $orientatedItem
133
     * @param int            $x
134
     * @param int            $y
135
     * @param int            $z
136
     *
137
     * @return PackedItem
138
     */
139 38
    public static function fromOrientatedItem(OrientatedItem $orientatedItem, $x, $y, $z)
140
    {
141 38
        return new static(
142 38
            $orientatedItem->getItem(),
143 38
            $x,
144 38
            $y,
145 38
            $z,
146 38
            $orientatedItem->getWidth(),
147 38
            $orientatedItem->getLength(),
148 38
            $orientatedItem->getDepth()
149
        );
150
    }
151
}
152
153