/**
  * @dataProvider provideDimensions
  */
 public function testNormalize(Dimensions $dimensions)
 {
     $math = new NativeMath();
     $normalizer = new DimensionsNormalizer($math);
     $result = $normalizer->normalize($dimensions);
     $this->assertGreaterThanOrEqual($result->getWidth(), $result->getLength());
     $this->assertGreaterThanOrEqual($result->getHeight(), $result->getWidth());
     $this->assertSame($dimensions->getUnit(), $result->getUnit());
 }
 /**
  * @param DimensionsInterface $dimensions
  * @return Length
  */
 public function calculate(DimensionsInterface $dimensions)
 {
     $dimensions = $this->dimensionsNormalizer->normalize($dimensions);
     $value = $this->math->sum($dimensions->getLength(), $dimensions->getWidth());
     $value = $this->math->mul($value, 2);
     $perimeter = new Length();
     $perimeter->setUnit($dimensions->getUnit());
     $perimeter->setValue($value);
     return $perimeter;
 }
 /**
  * @param Dimensions $dimensions
  * @return Length
  */
 public function calculate(Dimensions $dimensions)
 {
     $dimensions = $this->dimensionsNormalizer->normalize($dimensions);
     $value = $dimensions->getLength();
     $value = $this->math->sum($value, $this->math->mul($dimensions->getWidth(), 2));
     $value = $this->math->sum($value, $this->math->mul($dimensions->getHeight(), 2));
     $girth = new Length();
     $girth->setUnit($dimensions->getUnit());
     $girth->setValue($value);
     return $girth;
 }