Checks/fixes so the invNo input is valid.

@param string &$invNo Invoice number.

@throws KlarnaException
@return void
431685
private function _checkInvNo(&$invNo)
    {
        if (!isset($invNo)) {
            throw new Klarna_ArgumentNotSetException("Invoice number");
        }
        if (!is_string($invNo)) {
            $invNo = strval($invNo);
        }
        if (strlen($invNo) == 0) {
            throw new Klarna_ArgumentNotSetException("Invoice number");
        }
    }
1155051
public function transformFromOrder(OrderInterface $order, InvoiceInterface $invoice)
    {
        $event = new OrderTransformEvent($order);
        $this->eventDispatcher->dispatch(TransformerEvents::PRE_ORDER_TO_INVOICE_TRANSFORM, $event);

        $invoice->setName($order->getBillingName());
        $invoice->setAddress1($order->getBillingAddress1());
        $invoice->setAddress2($order->getBillingAddress2());
        $invoice->setAddress3($order->getBillingAddress3());
        $invoice->setCity($order->getBillingCity());
        $invoice->setCountry($order->getBillingCountryCode());
        $invoice->setPostcode($order->getBillingPostcode());

        $invoice->setEmail($order->getBillingEmail());
        $invoice->setFax($order->getBillingFax());
        $invoice->setMobile($order->getBillingMobile());
        $invoice->setPhone($order->getBillingPhone());
        $invoice->setReference($order->getReference());

        $invoice->setCurrency($order->getCurrency());
        $invoice->setCustomer($order->getCustomer());
        $invoice->setTotalExcl($order->getTotalExcl());
        $invoice->setTotalInc($order->getTotalInc());

        $invoice->setPaymentMethod($order->getPaymentMethod());

        $invoice->setLocale($order->getLocale());

        foreach ($order->getOrderElements() as $orderElement) {
            $invoiceElement = $this->createInvoiceElementFromOrderElement($orderElement);
            $invoiceElement->setInvoice($invoice);
            $invoice->addInvoiceElement($invoiceElement);
        }

        if ($order->getDeliveryCost() > 0) {
            $this->addDelivery($invoice, $order);
        }

        $invoice->setStatus(InvoiceInterface::STATUS_OPEN);

        $event = new InvoiceTransformEvent($invoice);
        $this->eventDispatcher->dispatch(TransformerEvents::POST_ORDER_TO_INVOICE_TRANSFORM, $event);
    }
164871
private function _checkLanguage(&$language)
    {
        if (!isset($language)) {
            throw new Klarna_ArgumentNotSetException("Language");
        }
        if (is_numeric($language) && !is_int($language)) {
            $language = intval($language);
        }
        if (!is_numeric($language) || !is_int($language)) {
            throw new Klarna_InvalidTypeException("Language", "integer");
        }
    }
1302630
private function assertOptionName(string $option): void
	{
		static $validOptions = [
			'delimiter',
			'validChars',
			'ignoreChars',
			'locale',
			'transforms',
			'preTransforms',
			'postTransforms',
		];

		if (!in_array($option, $validOptions, true)) {
			throw new \InvalidArgumentException(sprintf('Unknown option "%s"', $option));
		}
	}
173154
private function _checkArtNo(&$artNo)
    {
        if (is_numeric($artNo) && !is_string($artNo)) {
            //Convert artNo to string if integer.
            $artNo = strval($artNo);
        }
        if (!isset($artNo) || strlen($artNo) == 0 || (!is_string($artNo))) {
            throw new Klarna_ArgumentNotSetException("artNo");
        }
    }
1284041
function validateService($pluginInstance)
    {
        if (!is_callable($pluginInstance))
            throw new exContainerInvalidServiceType(sprintf(
                'Plugin must be callable; given:(%s).'
                , \Poirot\Std\flatten($pluginInstance)
            ));
    }
438782
public function validatePlugin($plugin)
    {
        if ($plugin instanceof UiAdapter\UiAdapterInterface) {
            // we're okay
            return;
        }

        throw new Exception\InvalidArgumentException(sprintf(
            'Plugin of type %s is invalid; must extend %s\UiAdapter\UiAdapterInterface',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            __NAMESPACE__
        ));
    }
437858
public function validatePlugin($service)
    {
        if ($service instanceof ServiceInterface) {
            return;
        }

        throw new InvalidPluginException(sprintf(
            'Plugin of type %s is invalid; must implement %s\Service\ServiceInterface',
            (is_object($service) ? get_class($service) : gettype($service)),
            __NAMESPACE__
        ));
    }
65601
private function _checkEstoreOrderNo(&$estoreOrderNo)
    {
        if (!isset($estoreOrderNo)) {
            throw new Klarna_ArgumentNotSetException("Order number");
        }

        if (!is_string($estoreOrderNo)) {
            $estoreOrderNo = strval($estoreOrderNo);
            if (!is_string($estoreOrderNo)) {
                throw new Klarna_InvalidTypeException("Order number", "string");
            }
        }
    }
438445
private function createOperationsFromInvoice(array $invoice, VendorInterface $vendor, DateTime $cycleDate)
    {
        if ($invoice['summary']['amount_transferred'] > 0) {

            $operations = array();

            try {
                // Calculate adjusted amount (for past negative operations)
                $adjustedInfos = $this->getAdjustedAmount($invoice['summary']['amount_transferred'], $vendor);

                $this->logger->debug(
                    "Vendor origin amount " . $invoice['summary']['amount_transferred'],
                    array('miraklId' => $invoice['shop_id'], "action" => "Operations creation")
                );

                $this->logger->debug(
                    "Vendor adjusted amount " .
                    $adjustedInfos['adjustedAmount'] .
                    " (" .
                    count($adjustedInfos['adujstedOperationsIds']) .
                    " operations adjusted)",
                    array('miraklId' => $invoice['shop_id'], "action" => "Operations creation")
                );

                // Vendor operation
                $operations[] = $this->createOperation(
                    $adjustedInfos['adjustedAmount'],
                    $invoice['summary']['amount_transferred'],
                    $cycleDate,
                    $invoice['invoice_id'],
                    $vendor,
                    $adjustedInfos['adujstedOperationsIds']
                );

                // operator operation
                $operations[] = $this->createOperation(
                    $invoice['total_charged_amount'],
                    null,
                    $cycleDate,
                    $invoice['invoice_id'],
                    $this->operator
                );

                // save in memory for future saving in database
                $this->adjustedOperations = array_merge(
                    $this->adjustedOperations,
                    $adjustedInfos["adujstedOperations"]
                );

                return $operations;
            } catch (Exception $e) {
                $this->handleException($e);
                return false;
            }
        } else {
            $this->logger->warning(
                "Invoice n° " . $invoice['invoice_id'] . " has a negative amount, will not be treated",
                array('miraklId' => $invoice['shop_id'], "action" => "Operations creation")
            );
        }
    }
318474
protected function triggerInvoiceCreated(array &$invoice, Source $invoiceSource, Result $localResult)
    {
        /** @noinspection PhpUnhandledExceptionInspection */
        Hook::exec('actionAcumulusInvoiceCreated', array('invoice' => &$invoice, 'source' => $invoiceSource, 'localResult' => $localResult));
    }
987300
public function setCorrectionRequestDocflow(\AgentSIB\Diadoc\Api\Proto\Docflow\InvoiceCorrectionRequestDocflow $value = null)
    {
        $this->CorrectionRequestDocflow = $value;
    }
1284221
private function addInvoice($trans, $invoice_no, $ref_no, $options)
    {
        $trans->addChild('InvoiceNo', $invoice_no);
        $trans->addChild('RefNo', $ref_no ?: $invoice_no);
        if ($options['merchant']) {
            $trans->addChild('OperatorID', $options['merchant']);
        }
        if ($options['description']) {
            $trans->addChild('Memo', $options['description']);
        }
    }
1131531
public function updateOrderNo($invNo, $orderid)
    {
        $this->_checkInvNo($invNo);
        $this->_checkEstoreOrderNo($orderid);

        $digestSecret = self::digest(
            $this->colon($invNo, $orderid, $this->_secret)
        );

        $paramList = array(
            $this->_eid,
            $digestSecret,
            $invNo,
            $orderid
        );

        self::printDebug('update_orderno array', $paramList);

        $result = $this->xmlrpc_call('update_orderno', $paramList);

        return $result;
    }
696538
public function validatePlugin($plugin)
    {
        try {
            $this->validate($plugin);
        } catch (InvalidServiceException $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
        }
    }
159066
public function setInvoice(\AgentSIB\Diadoc\Api\Proto\Recognition\RecognizedInvoice $value = null)
    {
        $this->Invoice = $value;
    }
887288
public function setInvoiceCorrectionRevisionStatus(\AgentSIB\Diadoc\Api\Proto\Documents\InvoiceDocument\InvoiceStatus $value = null)
    {
        $this->InvoiceCorrectionRevisionStatus = $value;
    }