예제 #1
0
 /**
  * Formats a Money object using PHP's built-in NumberFormatter.
  *
  * @param  Money $money
  * @return string
  */
 public function format(Money $money = null)
 {
     if (!$money) {
         return null;
     } else {
         return $this->numberFormatter->formatCurrency($money->getAmount() / $money->getCurrency()->getSubUnit(), $money->getCurrency()->getCurrencyCode());
     }
 }
예제 #2
0
 /**
  * @param  Money $a
  * @param  Money $b
  * @throws CurrencyMismatchException
  */
 private function assertSameCurrency(Money $a, Money $b)
 {
     if ($a->getCurrency() != $b->getCurrency()) {
         throw new CurrencyMismatchException();
     }
 }