1 | <?php |
||
18 | class VolumePacker implements LoggerAwareInterface |
||
19 | { |
||
20 | use LoggerAwareTrait; |
||
21 | |||
22 | /** |
||
23 | * Box to pack items into |
||
24 | * @var Box |
||
25 | */ |
||
26 | protected $box; |
||
27 | |||
28 | /** |
||
29 | * List of items to be packed |
||
30 | * @var ItemList |
||
31 | */ |
||
32 | protected $items; |
||
33 | |||
34 | /** |
||
35 | * Remaining width of the box to pack items into |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $widthLeft; |
||
39 | |||
40 | /** |
||
41 | * Remaining length of the box to pack items into |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $lengthLeft; |
||
45 | |||
46 | /** |
||
47 | * Remaining depth of the box to pack items into |
||
48 | * @var int |
||
49 | */ |
||
50 | protected $depthLeft; |
||
51 | |||
52 | /** |
||
53 | * Remaining weight capacity of the box |
||
54 | * @var int |
||
55 | */ |
||
56 | protected $remainingWeight; |
||
57 | |||
58 | /** |
||
59 | * Used width inside box for packing items |
||
60 | * @var int |
||
61 | */ |
||
62 | protected $usedWidth = 0; |
||
63 | |||
64 | /** |
||
65 | * Used length inside box for packing items |
||
66 | * @var int |
||
67 | */ |
||
68 | protected $usedLength = 0; |
||
69 | |||
70 | /** |
||
71 | * Used depth inside box for packing items |
||
72 | * @var int |
||
73 | */ |
||
74 | protected $usedDepth = 0; |
||
75 | |||
76 | /** |
||
77 | * @var int |
||
78 | */ |
||
79 | protected $layerWidth = 0; |
||
80 | |||
81 | /** |
||
82 | * @var int |
||
83 | */ |
||
84 | protected $layerLength = 0; |
||
85 | |||
86 | /** |
||
87 | * @var int |
||
88 | */ |
||
89 | protected $layerDepth = 0; |
||
90 | |||
91 | /** |
||
92 | * Constructor |
||
93 | * |
||
94 | * @param Box $box |
||
95 | * @param ItemList $items |
||
96 | */ |
||
97 | 33 | public function __construct(Box $box, ItemList $items) |
|
109 | |||
110 | /** |
||
111 | * Pack as many items as possible into specific given box |
||
112 | * @return PackedBox packed box |
||
113 | */ |
||
114 | 33 | public function pack() |
|
198 | |||
199 | /** |
||
200 | * @param Item $itemToPack |
||
201 | * @param OrientatedItem|null $prevItem |
||
202 | * @param Item|null $nextItem |
||
203 | * @param int $maxWidth |
||
204 | * @param int $maxLength |
||
205 | * @param int $maxDepth |
||
206 | * |
||
207 | * @return OrientatedItem|false |
||
208 | */ |
||
209 | 33 | protected function getOrientationForItem( |
|
237 | |||
238 | /** |
||
239 | * Figure out if we can stack the next item vertically on top of this rather than side by side |
||
240 | * Used when we've packed a tall item, and have just put a shorter one next to it |
||
241 | * |
||
242 | * @param ItemList $packedItems |
||
243 | * @param OrientatedItem $prevItem |
||
|
|||
244 | * @param Item $nextItem |
||
245 | * @param int $maxWidth |
||
246 | * @param int $maxLength |
||
247 | * @param int $maxDepth |
||
248 | */ |
||
249 | 33 | protected function tryAndStackItemsIntoSpace( |
|
275 | |||
276 | /** |
||
277 | * @return bool |
||
278 | */ |
||
279 | 25 | protected function isLayerStarted() |
|
283 | |||
284 | /** |
||
285 | * As well as purely dimensional constraints, there are other constraints that need to be met |
||
286 | * e.g. weight limits or item-specific restrictions (e.g. max <x> batteries per box) |
||
287 | * |
||
288 | * @param Item $itemToPack |
||
289 | * @param ItemList $packedItems |
||
290 | * |
||
291 | * @return bool |
||
292 | */ |
||
293 | 33 | protected function checkNonDimensionalConstraints(Item $itemToPack, ItemList $packedItems) |
|
303 | } |
||
304 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.