code: protected function generateNumber(InvoiceInterface $invoice)
      {
          if (0 == strlen($invoice->getNumber())) {
              if (InvoiceTypes::isInvoice($invoice)) {
                  $this->invoiceNumberGenerator->generate($invoice);
              } elseif (InvoiceTypes::isCredit($invoice)) {
                  $this->creditNumberGenerator->generate($invoice);
              } else {
                  throw new Exception\InvalidArgumentException("Unexpected invoice type.");
              }
  
              return true;
          }
  
          return false;
      }
docs: Generates the number.
  
  @param InvoiceInterface $invoice
  
  @return bool Whether the invoice number has been generated or not.