/**
  * Calculate the required wrapping paper area for given box plus
  * the smallest side extra used for overlap
  *
  * @param Box $box
  * @return int|float
  */
 public function calculateWrappingPaper(Box $box)
 {
     $top = $box->getLength() * $box->getWidth();
     $side = $box->getWidth() * $box->getHeight();
     $front = $box->getHeight() * $box->getLength();
     $extra = min($top, $side, $front);
     return 2 * $top + 2 * $side + 2 * $front + $extra;
 }
示例#2
0
 public function testGetLength()
 {
     $box = new Box(5);
     $length = $box->getLength();
     $this->assertEquals(5, $length);
 }