Total Complexity | 7 |
Total Lines | 98 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
18 | class OrientatedItem |
||
19 | { |
||
20 | /** |
||
21 | * @var Item |
||
22 | */ |
||
23 | protected $item; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | protected $width; |
||
29 | |||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | protected $length; |
||
34 | |||
35 | /** |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $depth; |
||
39 | |||
40 | /** |
||
41 | * Constructor. |
||
42 | * |
||
43 | * @param Item $item |
||
44 | * @param int $width |
||
45 | * @param int $length |
||
46 | * @param int $depth |
||
47 | */ |
||
48 | 21 | public function __construct(Item $item, int $width, int $length, int $depth) |
|
49 | { |
||
50 | 21 | $this->item = $item; |
|
51 | 21 | $this->width = $width; |
|
52 | 21 | $this->length = $length; |
|
53 | 21 | $this->depth = $depth; |
|
54 | 21 | } |
|
55 | |||
56 | /** |
||
57 | * Item. |
||
58 | * |
||
59 | * @return Item |
||
60 | */ |
||
61 | 21 | public function getItem(): Item |
|
62 | { |
||
63 | 21 | return $this->item; |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * Item width in mm in it's packed orientation. |
||
68 | * |
||
69 | * @return int |
||
70 | */ |
||
71 | 21 | public function getWidth(): int |
|
72 | { |
||
73 | 21 | return $this->width; |
|
74 | } |
||
75 | |||
76 | /** |
||
77 | * Item length in mm in it's packed orientation. |
||
78 | * |
||
79 | * @return int |
||
80 | */ |
||
81 | 21 | public function getLength(): int |
|
82 | { |
||
83 | 21 | return $this->length; |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * Item depth in mm in it's packed orientation. |
||
88 | * |
||
89 | * @return int |
||
90 | */ |
||
91 | 21 | public function getDepth(): int |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * Calculate the surface footprint of the current orientation |
||
98 | * |
||
99 | * @return int |
||
100 | */ |
||
101 | 18 | public function getSurfaceFootprint(): int |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * Is this item stable (low centre of gravity), calculated as if the tipping point is >15 degrees. |
||
108 | * |
||
109 | * N.B. Assumes equal weight distribution. |
||
110 | * |
||
111 | * @return bool |
||
112 | */ |
||
113 | 21 | public function isStable(): bool |
|
118 |