/** * @return array */ public function getFilters() { return [new \Twig_SimpleFilter('formatCurrency', function ($money) { if (!$money instanceof Money && is_int($money)) { $money = new Money($money, $this->currency); } return $this->formatter->format($money); })]; }
/** * @param string $locale * @param string $currency * @param string $format * * @dataProvider localeProvider */ public function testFormatCurrencyWithDefaultValues($locale, $currency, $format) { $formatter = new MoneyFormatter($locale); $currency = new Currency($currency); $money = new Money(1200, $currency); $this->assertSame($format, $formatter->format($money)); }
/** * @param XmlSerializationVisitor $visitor * @param Money $money */ public function serializeMoneyXml(XmlSerializationVisitor $visitor, Money $money) { /** @var \DOMElement $node */ $node = $visitor->getCurrentNode(); $node->nodeValue = $this->formatter->format($money); }
/** * {@inheritdoc} */ public function getDisplayedValue($value) { return $this->formatter->format($value); }