diego-brocanelli / money_to_word
Convert money into text
2.0.0
2020-12-30 18:13 UTC
Requires
- php: >=7.4
- ext-intl: *
Requires (Dev)
- phpstan/phpstan: 0.12.x-dev
- phpunit/phpunit: 10.0.x-dev
- squizlabs/php_codesniffer: 4.0.x-dev
This package is auto-updated.
Last update: 2025-03-29 00:57:16 UTC
README
The goal is to convert the numbers (string) set to text.
Requirements
. PHP >= 7.4;
. ext-intl.
Install
composer install
Run tests
In the project root.
composer tests
Run code analysis
In the project root.
composer analyse
Run PHP Code Sniffer
In the project root.
composer phpcs
Run Tests, analysis and PHP Code Sniffer
In the project root.
composer all
How to use
composer require diego-brocanelli/money_to_word dev-main
Examples:
BRL
<?php require_once __DIR__ . '/vendor/autoload.php'; use Money\Coins\BRL; use Money\MoneyToWords; $money = new MoneyToWords(new BRL()); $money->convert(0.1); // output: dez centavo $money->convert(0.01); // output: um centavo $money->convert(0.05); // output: cinco centavos $money->convert(1.0); // output: um real $money->convert(125.67); // output: cento e vinte e cinco reais e sessenta e sete centavos $money->convert(8563754.01); // output: oito milhões e quinhentos e sessenta e três mil e setecentos e cinquenta e quatro reais e um centavo $money->convert(1.01); // output: um real e um centavo $money->convert(111.11); // output: cento e onze reais e onze centavos $money->convert(25.0); // output: vinte e cinco reais $money->convert(1.25); // output: um real e vinte e cinco centavos $money->convert(7596.37); // output: sete mil e quinhentos e noventa e seis reais e trinta e sete centavos $money->convert(1000000000); // output: um bilhão de reais $money->convert(1829672.99); // output: um milhão e oitocentos e vinte e nove mil e seiscentos e setenta e dois reais e noventa e nove centavos $money->convert(0.5); // output: cinquenta centavos