/** * Figure out if we can stack the next item vertically on top of this rather than side by side * Used when we've packed a tall item, and have just put a shorter one next to it * @param Item $item * @param Item $nextItem * @param $maxStackDepth * @param $remainingWeight * @return bool */ protected function canStackItemInLayer(Item $item, Item $nextItem, $maxStackDepth, $remainingWeight) { return $nextItem->getDepth() <= $maxStackDepth && $nextItem->getWeight() <= $remainingWeight && $nextItem->getWidth() <= $item->getWidth() && $nextItem->getLength() <= $item->getLength(); }