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

        $node = $document->createElement('Shipment');

        if ($this->getFreightCharges() instanceof FreightCharges) {
            $node->appendChild($this->getFreightCharges()->toNode($document));
        }

        // Then the required values
        $node->appendChild($document->createElement('OriginCountryCode', $this->getOriginCountryCode()));
        $node->appendChild($document->createElement('DestinationCountryCode', $this->getDestinationCountryCode()));

        // Then the optional values
        if ($this->getOriginStateProvinceCode() !== null) {
            $node->appendChild(
                $document->createElement(
                    'OriginStateProvinceCode',
                    $this->getOriginStateProvinceCode()
                )
            );
        }
        if ($this->getDestinationStateProvinceCode() !== null) {
            $node->appendChild(
                $document->createElement(
                    'DestinationStateProvinceCode',
                    $this->getDestinationStateProvinceCode()
                )
            );
        }
        if ($this->getTransportationMode() !== null) {
            $node->appendChild($document->createElement('TransportationMode', $this->getTransportationMode()));
        }
        if ($this->getResultCurrencyCode() !== null) {
            $node->appendChild($document->createElement('ResultCurrencyCode', $this->getResultCurrencyCode()));
        }
        if ($this->getTariffCodeAlert() !== null) {
            $node->appendChild($document->createElement('TariffCodeAlert', $this->getTariffCodeAlert()));
        }
        if ($this->getTransactionReferenceId() !== null) {
            $node->appendChild($document->createElement('TransactionReferenceID', $this->getTransactionReferenceId()));
        }

        // Then products array
        foreach ($this->products as $product) {
            $node->appendChild($product->toNode($document));
        }

        // Return created node
        return $node;
    }
public function toNode(DOMDocument $document = null)
    {
        if (null === $document) {
            $document = new DOMDocument();
        }

        $node = $document->createElement('Shipment');

        if ($this->getFreightCharges() instanceof FreightCharges) {
            $node->appendChild($this->getFreightCharges()->toNode($document));
        }

        // Then the required values
        $node->appendChild($document->createElement('OriginCountryCode', $this->getOriginCountryCode()));
        $node->appendChild($document->createElement('DestinationCountryCode', $this->getDestinationCountryCode()));

        // Then the optional values
        if ($this->getOriginStateProvinceCode() !== null) {
            $node->appendChild(
                $document->createElement(
                    'OriginStateProvinceCode',
                    $this->getOriginStateProvinceCode()
                )
            );
        }
        if ($this->getDestinationStateProvinceCode() !== null) {
            $node->appendChild(
                $document->createElement(
                    'DestinationStateProvinceCode',
                    $this->getDestinationStateProvinceCode()
                )
            );
        }
        if ($this->getTransportationMode() !== null) {
            $node->appendChild($document->createElement('TransportationMode', $this->getTransportationMode()));
        }
        if ($this->getResultCurrencyCode() !== null) {
            $node->appendChild($document->createElement('ResultCurrencyCode', $this->getResultCurrencyCode()));
        }
        if ($this->getTariffCodeAlert() !== null) {
            $node->appendChild($document->createElement('TariffCodeAlert', $this->getTariffCodeAlert()));
        }
        if ($this->getTransactionReferenceId() !== null) {
            $node->appendChild($document->createElement('TransactionReferenceID', $this->getTransactionReferenceId()));
        }

        // Then products array
        foreach ($this->products as $product) {
            $node->appendChild($product->toNode($document));
        }

        // Return created node
        return $node;
    }
public function toNode ( DOMDocument $ document = null ) { if ( null === $ document ) { $ document = new DOMDocument ( ) ; } $ node = $ document -> createElement ( 'Shipment' ) ; if ( $ this -> getFreightCharges ( ) instanceof FreightCharges ) { $ node -> appendChild ( $ this -> getFreightCharges ( ) -> toNode ( $ document ) ) ; } // Then the required values $ node -> appendChild ( $ document -> createElement ( 'OriginCountryCode' , $ this -> getOriginCountryCode ( ) ) ) ; $ node -> appendChild ( $ document -> createElement ( 'DestinationCountryCode' , $ this -> getDestinationCountryCode ( ) ) ) ; // Then the optional values if ( $ this -> getOriginStateProvinceCode ( ) !== null ) { $ node -> appendChild ( $ document -> createElement ( 'OriginStateProvinceCode' , $ this -> getOriginStateProvinceCode ( ) ) ) ; } if ( $ this -> getDestinationStateProvinceCode ( ) !== null ) { $ node -> appendChild ( $ document -> createElement ( 'DestinationStateProvinceCode' , $ this -> getDestinationStateProvinceCode ( ) ) ) ; } if ( $ this -> getTransportationMode ( ) !== null ) { $ node -> appendChild ( $ document -> createElement ( 'TransportationMode' , $ this -> getTransportationMode ( ) ) ) ; } if ( $ this -> getResultCurrencyCode ( ) !== null ) { $ node -> appendChild ( $ document -> createElement ( 'ResultCurrencyCode' , $ this -> getResultCurrencyCode ( ) ) ) ; } if ( $ this -> getTariffCodeAlert ( ) !== null ) { $ node -> appendChild ( $ document -> createElement ( 'TariffCodeAlert' , $ this -> getTariffCodeAlert ( ) ) ) ; } if ( $ this -> getTransactionReferenceId ( ) !== null ) { $ node -> appendChild ( $ document -> createElement ( 'TransactionReferenceID' , $ this -> getTransactionReferenceId ( ) ) ) ; } // Then products array foreach ( $ this -> products as $ product ) { $ node -> appendChild ( $ product -> toNode ( $ document ) ) ; } // Return created node return $ node ; }
@param null|DOMDocument $document

@return DOMElement
@param null|DOMDocument $document