/** * @param Currency $expected * @param Currency $actual * * @return CurrencyMismatchException */ public static function currencyMismatch(Currency $expected, Currency $actual) { return new self(sprintf('Currency mismatch: expected %s, got %s', $expected->getCode(), $actual->getCode())); }
/** * Returns the money in the given currency contained in the bag. * * If no money is present for the given currency, a zero-value money with the default scale * for the given currency will be returned. * * @param Currency $currency * * @return Money */ public function get(Currency $currency) { $currencyCode = $currency->getCode(); return isset($this->monies[$currencyCode]) ? $this->monies[$currencyCode] : Money::zero($currency); }
/** * Removes a currency from this currency provider. * * If no currency with this code is registered, this method does nothing. * * @param Currency $currency The currency to remove. * * @return ConfigurableCurrencyProvider This instance, for chaining. */ public function removeCurrency(Currency $currency) { unset($this->currencies[$currency->getCode()]); return $this; }