/** * @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 DimensionsInterface $dimensions * @return Length */ public function calculate(DimensionsInterface $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; }