Skip to content

Commit

Permalink
Adding all the Speller methods as Twig filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
jurchiks authored Oct 1, 2019
1 parent d716117 commit 46d508b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Twig/Spell.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
<?php

namespace js\tools\numbers2words\Twig;

use Twig\TwigFilter;
use js\tools\numbers2words\Speller;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

class Spell extends AbstractExtension
{
public function getFilters()
{
return [
new TwigFilter('spellNumber', [$this, 'spellNumber']),
new TwigFilter('spellCurrencyShort', [$this, 'spellCurrencyShort']),
new TwigFilter('spellCurrency', [$this, 'spellCurrency']),
];
}

public function spellNumber($number, $language)
{
return Speller::spellNumber($number, $language);
}

public function spellCurrencyShort($amount, $language, $currency)
{
return Speller::spellCurrencyShort($amount, $language, $currency);
}

public function spellCurrency($amount, $language, $currency, $requireDecimal = true, $spellDecimal = false)
{
return Speller::spellCurrency($amount, $language, $currency, $requireDecimal, $spellDecimal);
}
}

0 comments on commit 46d508b

Please sign in to comment.