for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Box packing (3D bin packing, knapsack problem)
* @package BoxPacker
* @author Doug Wright
*/
namespace DVDoug\BoxPacker;
* An item to be packed
class OrientatedItem
{
* @var Item
protected $item;
* @var int
protected $width;
protected $length;
protected $depth;
* Constructor.
* @param Item $item
* @param int $width
* @param int $length
* @param int $depth
public function __construct(Item $item, $width, $length, $depth) {
$this->item = $item;
$this->width = $width;
$this->length = $length;
$this->depth = $depth;
}
* Item
*
* @return Item
public function getItem() {
return $this->item;
* Item width in mm in it's packed orientation
* @return int
public function getWidth() {
return $this->width;
* Item length in mm in it's packed orientation
public function getLength() {
return $this->length;
* Item depth in mm in it's packed orientation
public function getDepth() {
return $this->depth;
* Is this orientation stable (low centre of gravity)
* N.B. Assumes equal weight distribution
* @return bool
public function isStable() {
return $this->getDepth() <= min($this->getLength(), $this->getWidth());