コード例 #1
0
 /**
  * @author Krzysztof Bednarczyk
  * @param Money|null $money
  * @return null
  */
 public function priceCalculator($money)
 {
     if (!$money || !$money instanceof Money) {
         return null;
     }
     $currency = $this->container->get('bordeux.language.manager')->getCurrentLanguage()->getCurrency();
     if ($money->getCurrency()->getId() === $currency->getId()) {
         return $money->format();
     }
     return $money->format() . ' / ' . $currency->convert($money)->format();
 }
コード例 #2
0
ファイル: Currency.php プロジェクト: bordeux/language-bundle
 /**
  * @author Krzysztof Bednarczyk
  * @param Money $money
  * @return Money
  */
 public function convert(Money $money)
 {
     $converted = new Money();
     $converted->setCurrency($this);
     $result = $money->getAmount() * ($this->getValue() / $money->getCurrency()->getValue());
     $converted->setAmount(round($result, 4));
     return $converted;
 }