Ejemplo n.º 1
0
 /**
  * @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);
     })];
 }
Ejemplo n.º 2
0
 /**
  * @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));
 }
Ejemplo n.º 3
0
 /**
  * @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);
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function getDisplayedValue($value)
 {
     return $this->formatter->format($value);
 }