-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding all the Speller methods as Twig filters.
- Loading branch information
Showing
1 changed file
with
13 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |