sat-suite/number-to-words

Currency based number to words converted

v0.2.1 2022-01-18 14:58 UTC

This package is auto-updated.

Last update: 2024-10-18 21:08:57 UTC


README

Currency based number to words converted

Usage

use SatSuite\NumberToWords\Words;

$converter = new Words();
$words = $converter->from('100.01', 'MXN');

// USD
$words = $converter->from('100.01', 'USD');

// EUR
$words = $converter->from('100.01', 'EUR');

Register new currencies

use SatSuite\NumberToWords\Words;
use SatSuite\NumberToWords\CurrencyManager;
use SatSuite\NumberToWords\Currencies\Currency;

class CanadianDolar extends Currency
{
    public function getName()
    {
        return 'CAD';
    }

    public function getMeta()
    {
        return [
            'singular' => 'DÓLAR',
            'plural' => 'DÓLARES',
            'prefix' => 'CAD',
            'sufix' => 'CAD',
            'symbol' => 'CAD.',

        ];
    }
}

$manager = new CurrencyManager();
$manager->register(new CanadianDolar());

$converter = new Words($manager);
$words = $converter->from('100.01', 'CAD);