private function checkShipmentInvoice(Invoice\InvoiceInterface $invoice)
    {
        if (null === $shipment = $invoice->getShipment()) {
            throw new LogicException("Invoice's shipment must be set at this point.");
        }

        // Check sale integrity
        if ($shipment->getSale() !== $sale = $invoice->getSale()) {
            throw new LogicException("Shipment/Invoice sale miss match.");
        }

        // Sale must be a invoice subject
        if (!$sale instanceof Invoice\InvoiceSubjectInterface) {
            throw new LogicException("Expected instance of " . Invoice\InvoiceSubjectInterface::class);
        }

        // Check shipment/invoice types integrity.
        if ($shipment->isReturn() && !Invoice\InvoiceTypes::isCredit($invoice)) {
            throw new LogicException("Invoice should not be associated with Return.");
        } elseif (!$shipment->isReturn() && !Invoice\InvoiceTypes::isInvoice($invoice)) {
            throw new LogicException("Credit should not be associated with Shipment.");
        }
    }
private function checkShipmentInvoice(Invoice\InvoiceInterface $invoice)
    {
        if (null === $shipment = $invoice->getShipment()) {
            throw new LogicException("Invoice's shipment must be set at this point.");
        }

        // Check sale integrity
        if ($shipment->getSale() !== $sale = $invoice->getSale()) {
            throw new LogicException("Shipment/Invoice sale miss match.");
        }

        // Sale must be a invoice subject
        if (!$sale instanceof Invoice\InvoiceSubjectInterface) {
            throw new LogicException("Expected instance of " . Invoice\InvoiceSubjectInterface::class);
        }

        // Check shipment/invoice types integrity.
        if ($shipment->isReturn() && !Invoice\InvoiceTypes::isCredit($invoice)) {
            throw new LogicException("Invoice should not be associated with Return.");
        } elseif (!$shipment->isReturn() && !Invoice\InvoiceTypes::isInvoice($invoice)) {
            throw new LogicException("Credit should not be associated with Shipment.");
        }
    }
private function checkShipmentInvoice ( Invoice \ InvoiceInterface $ invoice ) { if ( null === $ shipment = $ invoice -> getShipment ( ) ) { throw new LogicException ( "Invoice's shipment must be set at this point." ) ; } // Check sale integrity if ( $ shipment -> getSale ( ) !== $ sale = $ invoice -> getSale ( ) ) { throw new LogicException ( "Shipment/Invoice sale miss match." ) ; } // Sale must be a invoice subject if ( ! $ sale instanceof Invoice \ InvoiceSubjectInterface ) { throw new LogicException ( "Expected instance of " . Invoice \ InvoiceSubjectInterface :: class ) ; } // Check shipment/invoice types integrity. if ( $ shipment -> isReturn ( ) && ! Invoice \ InvoiceTypes :: isCredit ( $ invoice ) ) { throw new LogicException ( "Invoice should not be associated with Return." ) ; } elseif ( ! $ shipment -> isReturn ( ) && ! Invoice \ InvoiceTypes :: isInvoice ( $ invoice ) ) { throw new LogicException ( "Credit should not be associated with Shipment." ) ; } }
Checks that the given invoice is correctly configured for shipment synchronization.

@param Invoice\InvoiceInterface $invoice

@throws LogicException
Checks that the given invoice is correctly configured for shipment synchronization .