Beispiel #1
0
 /**
  * Returns the total of the monies contained in this bag, in the given currency.
  *
  * @param Currency          $currency  The currency to get the total in.
  * @param CurrencyConverter $converter The currency converter to use.
  *
  * @return Money The total in the given currency.
  */
 public function getTotal(Currency $currency, CurrencyConverter $converter)
 {
     $total = Money::zero($currency);
     $context = new ExactContext();
     foreach ($this->monies as $money) {
         $money = $converter->convert($money, $currency);
         $total = $total->plus($money, $context);
     }
     return $total;
 }