| Total Complexity | 7 |
| Total Lines | 99 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class OrientatedItem |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var Item |
||
| 19 | */ |
||
| 20 | protected $item; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var int |
||
| 24 | */ |
||
| 25 | protected $width; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var int |
||
| 29 | */ |
||
| 30 | protected $length; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var int |
||
| 34 | */ |
||
| 35 | protected $depth; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Constructor. |
||
| 39 | * |
||
| 40 | * @param Item $item |
||
| 41 | * @param int $width |
||
| 42 | * @param int $length |
||
| 43 | * @param int $depth |
||
| 44 | */ |
||
| 45 | 19 | public function __construct(Item $item, $width, $length, $depth) |
|
| 46 | { |
||
| 47 | 19 | $this->item = $item; |
|
| 48 | 19 | $this->width = $width; |
|
| 49 | 19 | $this->length = $length; |
|
| 50 | 19 | $this->depth = $depth; |
|
| 51 | 19 | } |
|
| 52 | |||
| 53 | /** |
||
| 54 | * Item. |
||
| 55 | * |
||
| 56 | * @return Item |
||
| 57 | */ |
||
| 58 | 19 | public function getItem() |
|
| 59 | { |
||
| 60 | 19 | return $this->item; |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Item width in mm in it's packed orientation. |
||
| 65 | * |
||
| 66 | * @return int |
||
| 67 | */ |
||
| 68 | 19 | public function getWidth() |
|
| 69 | { |
||
| 70 | 19 | return $this->width; |
|
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Item length in mm in it's packed orientation. |
||
| 75 | * |
||
| 76 | * @return int |
||
| 77 | */ |
||
| 78 | 19 | public function getLength() |
|
| 79 | { |
||
| 80 | 19 | return $this->length; |
|
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Item depth in mm in it's packed orientation. |
||
| 85 | * |
||
| 86 | * @return int |
||
| 87 | */ |
||
| 88 | 19 | public function getDepth() |
|
| 91 | } |
||
| 92 | |||
| 93 | |||
| 94 | /** |
||
| 95 | * Calculate the surface footprint of the current orientation |
||
| 96 | * |
||
| 97 | * @return int |
||
| 98 | */ |
||
| 99 | 12 | public function getSurfaceFootprint() |
|
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Is this item stable (low centre of gravity), calculated as if the tipping point is >15 degrees. |
||
| 106 | * |
||
| 107 | * N.B. Assumes equal weight distribution. |
||
| 108 | * |
||
| 109 | * @return bool |
||
| 110 | */ |
||
| 111 | 19 | public function isStable() |
|
| 116 |