diff --git a/src/Ups/Entity/Package.php b/src/Ups/Entity/Package.php index 6be45f24..e7fcbccd 100644 --- a/src/Ups/Entity/Package.php +++ b/src/Ups/Entity/Package.php @@ -73,7 +73,7 @@ class Package implements NodeInterface private $largePackage; /** - * @var Dimensions + * @var Dimensions|null */ private $dimensions; @@ -89,7 +89,6 @@ public function __construct($attributes = null) { $this->setPackagingType(new PackagingType); $this->setReferenceNumber(new ReferenceNumber); - $this->setDimensions(new Dimensions); $this->setPackageWeight(new PackageWeight); $this->setPackageServiceOptions(new PackageServiceOptions); @@ -146,7 +145,9 @@ public function toNode(DOMDocument $document = null) $node->appendChild($this->getPackagingType()->toNode($document)); $node->appendChild($this->getPackageWeight()->toNode($document)); - $node->appendChild($this->getDimensions()->toNode($document)); + if (null !== $this->getDimensions()) { + $node->appendChild($this->getDimensions()->toNode($document)); + } $node->appendChild($this->getPackageServiceOptions()->toNode($document)); return $node; } @@ -190,7 +191,7 @@ public function setDescription($description) } /** - * @return Dimensions + * @return Dimensions|null */ public function getDimensions() {