Skip to content

Commit

Permalink
add dhl dimensions validation
Browse files Browse the repository at this point in the history
  • Loading branch information
moriony committed Dec 3, 2015
1 parent 2ced302 commit dc34b02
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/CalculatorHandler/DhlCalculatorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ public function validateDimensions(PackageInterface $package)
$maxDimensions = $this->normalizeDimensions($this->get('maximum_dimensions'));
$dimensions = $this->normalizeDimensions($package->getDimensions());

if (!$dimensions->getHeight() || !$dimensions->getLength() || !$dimensions->getWidth()) {
throw new InvalidDimensionsException('Dimensions must be greater than zero.');
}

$maxLength = $converter->convert($maxDimensions->getLength(), $this->get('dimensions_unit'), $dimensions->getUnit());
if ($math->greaterThan($dimensions->getLength(), $maxLength)) {
throw new InvalidDimensionsException('Dimensions limit is exceeded.');
Expand Down

0 comments on commit dc34b02

Please sign in to comment.