for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Box packing (3D bin packing, knapsack problem).
*
* @author Doug Wright
*/
declare(strict_types=1);
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, int $width, int $length, int $depth)
$this->item = $item;
$this->width = $width;
$this->length = $length;
$this->depth = $depth;
}
* Item.
* @return Item
public function getItem(): Item
return $this->item;
* Item width in mm in it's packed orientation.
* @return int
public function getWidth(): int
return $this->width;
* Item length in mm in it's packed orientation.
public function getLength(): int
return $this->length;
* Item depth in mm in it's packed orientation.
public function getDepth(): int
return $this->depth;
* Is this orientation stable (low centre of gravity)
* N.B. Assumes equal weight distribution.
* @return bool
public function isStable(): bool
return $this->getDepth() <= min($this->getLength(), $this->getWidth());