Example #1
0
 public function convert(Money $m, $to_currency, $round = 'down')
 {
     $factor = $this->get_factor($m->currency(), $to_currency);
     if ($factor === null) {
         throw new MoneyConversionException("no conversion for {$m->currency()} -> {$to_currency}");
     }
     $units = Money::round($m->units() * $factor, $round);
     return new Money($units, $to_currency);
 }