Пример #1
0
 /**
  * @param $currencyTo
  * @return Money
  */
 public function convertToCurrency($currencyTo)
 {
     $currencyTo = Currency::getInstance($currencyTo);
     if ($crossCourse = $this->getCurrency()->getCrossCourse($currencyTo)) {
         $newMoney = $this->multiply($crossCourse);
         return new static($newMoney->getAmount(), $currencyTo);
     } else {
         throw new InvalidArgumentException(\Yii::t('skeeks/money', 'Unable to get the cross rate for the currency') . ' ' . $currencyTo->getCurrencyCode());
     }
 }
Пример #2
0
 /**
  * Объект текущей валюты
  *
  * @return Currency
  */
 public function getCurrencyObject()
 {
     return Currency::getInstance(\Yii::$app->money->currencyCode);
 }