src/Entity/Package.php
public function toNode(DOMDocument $document = null)
    {
        if (null === $document) {
            $document = new DOMDocument();
        }

        $packageNode = $document->createElement('Package');

        if ($this->getDescription()) {
            $packageNode->appendChild($document->createElement('Description', $this->getDescription()));
        }
        $packageNode->appendChild($this->getPackagingType()->toNode($document));
        $packageNode->appendChild($this->getPackageWeight()->toNode($document));


        if (null !== $this->getDimensions()) {
            $packageNode->appendChild($this->getDimensions()->toNode($document));
        }

        if ($this->isLargePackage()) {
            $packageNode->appendChild($document->createElement('LargePackageIndicator'));
        }

        if ($this->getAdditionalHandling()) {
            $packageNode->appendChild($document->createElement('AdditionalHandling'));
        }

        if ($this->getPackageServiceOptions()) {
            $packageNode->appendChild($this->getPackageServiceOptions()->toNode($document));
        }

        if ($this->getReferenceNumber()
            && !is_null($this->getReferenceNumber()->getCode())
            && !is_null($this->getReferenceNumber()->getValue())
        ) {
            $packageNode->appendChild($this->getReferenceNumber()->toNode($document));
        }
        
        if ($this->getReferenceNumber2()
            && !is_null($this->getReferenceNumber2()->getCode())
            && !is_null($this->getReferenceNumber2()->getValue())
        ) {
            $packageNode->appendChild($this->getReferenceNumber2()->toNode($document));
        }

        return $packageNode;
    }
public function toNode(DOMDocument $document = null)
    {
        if (null === $document) {
            $document = new DOMDocument();
        }

        $packageNode = $document->createElement('Package');

        if ($this->getDescription()) {
            $packageNode->appendChild($document->createElement('Description', $this->getDescription()));
        }
        $packageNode->appendChild($this->getPackagingType()->toNode($document));
        $packageNode->appendChild($this->getPackageWeight()->toNode($document));


        if (null !== $this->getDimensions()) {
            $packageNode->appendChild($this->getDimensions()->toNode($document));
        }

        if ($this->isLargePackage()) {
            $packageNode->appendChild($document->createElement('LargePackageIndicator'));
        }

        if ($this->getAdditionalHandling()) {
            $packageNode->appendChild($document->createElement('AdditionalHandling'));
        }

        if ($this->getPackageServiceOptions()) {
            $packageNode->appendChild($this->getPackageServiceOptions()->toNode($document));
        }

        if ($this->getReferenceNumber()
            && !is_null($this->getReferenceNumber()->getCode())
            && !is_null($this->getReferenceNumber()->getValue())
        ) {
            $packageNode->appendChild($this->getReferenceNumber()->toNode($document));
        }
        
        if ($this->getReferenceNumber2()
            && !is_null($this->getReferenceNumber2()->getCode())
            && !is_null($this->getReferenceNumber2()->getValue())
        ) {
            $packageNode->appendChild($this->getReferenceNumber2()->toNode($document));
        }

        return $packageNode;
    }
@param null|DOMDocument $document

@return DOMElement