1 | <?php |
||
25 | class Packer |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * Library class instance |
||
30 | * @var \gplcart\core\Library $library |
||
31 | */ |
||
32 | protected $library; |
||
33 | |||
34 | /** |
||
35 | * Convertor model class instance |
||
36 | * @var \gplcart\core\models\Convertor $convertor |
||
37 | */ |
||
38 | protected $convertor; |
||
39 | |||
40 | /** |
||
41 | * Box model class instanceS |
||
42 | * @var \gplcart\modules\packer\models\Box $box |
||
43 | */ |
||
44 | protected $box; |
||
45 | |||
46 | /** |
||
47 | * Packer constructor. |
||
48 | * @param Library $library |
||
49 | * @param Convertor $convertor |
||
50 | * @param Box $box |
||
51 | */ |
||
52 | public function __construct(Library $library, Convertor $convertor, Box $box) |
||
58 | |||
59 | /** |
||
60 | * Returns library class instance |
||
61 | * @return \DVDoug\BoxPacker\Packer |
||
62 | * @throws LogicException |
||
63 | */ |
||
64 | public function getPacker() |
||
74 | |||
75 | /** |
||
76 | * Pack a set of items into a given set of box types |
||
77 | * @param array $items |
||
78 | * @param array $boxes |
||
79 | * @return \DVDoug\BoxPacker\PackedBoxList |
||
80 | */ |
||
81 | public function pack(array $items, array $boxes) |
||
97 | |||
98 | /** |
||
99 | * Returns an array of boxes needed to fit all the order items |
||
100 | * @param array $order |
||
101 | * @param array $cart |
||
102 | * @return array |
||
103 | * @throws OutOfRangeException |
||
104 | * @throws UnexpectedValueException |
||
105 | */ |
||
106 | public function packOrder(array $order, array $cart) |
||
136 | |||
137 | /** |
||
138 | * Returns an array of packed boxes |
||
139 | * @param array $items |
||
140 | * @param array $boxes |
||
141 | * @return array |
||
142 | */ |
||
143 | public function getPackedBoxes(array $items, array $boxes) |
||
156 | |||
157 | /** |
||
158 | * Does an array of items fit into the box |
||
159 | * @param array $items |
||
160 | * @param array $box |
||
161 | * @return \DVDoug\BoxPacker\PackedBox |
||
162 | */ |
||
163 | public function fit(array $items, array $box) |
||
178 | |||
179 | /** |
||
180 | * Returns an array of items that fit into the box |
||
181 | * @param array $items |
||
182 | * @param array $box |
||
183 | * @return array |
||
184 | */ |
||
185 | public function getFitItems(array $items, array $box) |
||
196 | |||
197 | /** |
||
198 | * Prepare an array of boxes |
||
199 | * @param array $boxes |
||
200 | * @param array $items |
||
201 | */ |
||
202 | protected function prepareBoxes(array &$boxes, array $items) |
||
211 | |||
212 | /** |
||
213 | * Prepare an array of items |
||
214 | * @param array $items |
||
215 | * @param array $box |
||
216 | */ |
||
217 | protected function prepareItems(array &$items, array $box) |
||
223 | |||
224 | /** |
||
225 | * Converts unints in the box data |
||
226 | * @param array $box |
||
227 | * @param array $item |
||
228 | */ |
||
229 | protected function convertBox(array &$box, array $item) |
||
255 | |||
256 | /** |
||
257 | * Convert item units |
||
258 | * @param array $item |
||
259 | * @param array $box |
||
260 | */ |
||
261 | protected function convertItem(array &$item, array $box) |
||
279 | } |
||
280 |