| Total Complexity | 8 |
| Total Lines | 110 |
| Duplicated Lines | 0 % |
| Coverage | 90.48% |
| 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 | /** @var float */ |
||
| 38 | protected $tippingPoint; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Constructor. |
||
| 42 | * |
||
| 43 | * @param Item $item |
||
| 44 | * @param int $width |
||
| 45 | * @param int $length |
||
| 46 | * @param int $depth |
||
| 47 | */ |
||
| 48 | 19 | public function __construct(Item $item, $width, $length, $depth) |
|
| 49 | { |
||
| 50 | 19 | $this->item = $item; |
|
| 51 | 19 | $this->width = $width; |
|
| 52 | 19 | $this->length = $length; |
|
| 53 | 19 | $this->depth = $depth; |
|
| 54 | 19 | $this->tippingPoint = atan(min($this->length, $this->width) / $this->depth); |
|
| 55 | 19 | } |
|
| 56 | |||
| 57 | /** |
||
| 58 | * Item. |
||
| 59 | * |
||
| 60 | * @return Item |
||
| 61 | */ |
||
| 62 | 19 | public function getItem() |
|
| 63 | { |
||
| 64 | 19 | return $this->item; |
|
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Item width in mm in it's packed orientation. |
||
| 69 | * |
||
| 70 | * @return int |
||
| 71 | */ |
||
| 72 | 19 | public function getWidth() |
|
| 73 | { |
||
| 74 | 19 | return $this->width; |
|
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Item length in mm in it's packed orientation. |
||
| 79 | * |
||
| 80 | * @return int |
||
| 81 | */ |
||
| 82 | 19 | public function getLength() |
|
| 83 | { |
||
| 84 | 19 | return $this->length; |
|
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Item depth in mm in it's packed orientation. |
||
| 89 | * |
||
| 90 | * @return int |
||
| 91 | */ |
||
| 92 | 19 | public function getDepth() |
|
| 93 | { |
||
| 94 | 19 | return $this->depth; |
|
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Calculate the surface footprint of the current orientation. |
||
| 99 | * |
||
| 100 | * @return int |
||
| 101 | */ |
||
| 102 | 11 | public function getSurfaceFootprint() |
|
| 103 | { |
||
| 104 | 11 | return $this->width * $this->length; |
|
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @return float |
||
| 109 | */ |
||
| 110 | public function getTippingPoint() |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Is this item stable (low centre of gravity), calculated as if the tipping point is >15 degrees. |
||
| 117 | * |
||
| 118 | * N.B. Assumes equal weight distribution. |
||
| 119 | * |
||
| 120 | * @return bool |
||
| 121 | */ |
||
| 122 | 19 | public function isStable() |
|
| 125 | } |
||
| 126 | } |
||
| 127 |