Ejemplo n.º 1
0
 /**
  * @param  Invoice $invoice
  * @return string
  */
 protected function getIssueDateAddition(Invoice $invoice)
 {
     switch ($invoice->getStatus()) {
         case Invoice::STATUS_DRAFT:
         case Invoice::STATUS_SENT:
             if ($invoice->getDueDate() === null) {
                 return 'No due date';
             }
             $dueTime = $invoice->getDueDate()->diff($invoice->getIssueDate())->days;
             return sprintf('Due in %d %s', $dueTime, $dueTime === 1 ? 'day' : 'days');
         case Invoice::STATUS_LATE:
             $lateTime = $invoice->getDueDate()->diff($invoice->getIssueDate())->days;
             return sprintf('%d %s late', $lateTime, $lateTime === 1 ? 'day' : 'days');
         case Invoice::STATUS_PAID:
             $payTime = $invoice->getPayDate()->diff($invoice->getIssueDate())->days;
             return sprintf('Paid in %d %s', $payTime, $payTime === 1 ? 'day' : 'days');
     }
     throw new RuntimeException(sprintf('Invalid invoice status "%s"', $invoice->getStatus()));
 }