yadders / rupiah-redenom
A Laravel package to handle Rupiah redenomination.
Requires
- php: ^8.1
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0
- phpunit/phpunit: ^10.0|^11.0|^12.0
README
A simple Laravel package to help with the planned Indonesian Rupiah redenomination. This package provides a simple way to "simplify" a Rupiah value (e.g., from 1,000 to 1) and format it.
Installation
You can install the package via composer:
composer require yadders/rupiah-redenom
The package will automatically register its service provider and facade.
Usage
You can use the Rupiah facade to access the package's functionality.
Simplifying Rupiah Values
The simplifyRupiah method divides a given value by 1000 (the default divisor for the redenomination).
use Yadders\RupiahRedenom\Facades\Rupiah; // Basic simplification $oldRupiah = 1000000; $newRupiah = Rupiah::simplifyRupiah($oldRupiah); // Returns 1000.0 $anotherOldRupiah = 5500; $anotherNewRupiah = Rupiah::simplifyRupiah($anotherOldRupiah); // Returns 5.5
You can also provide a custom divisor:
use Yadders\RupiahRedenom\Facades\Rupiah; $value = 10000; $simplified = Rupiah::simplifyRupiah($value, 100); // Returns 100.0
Formatting as Rupiah
The format method formats a number into a Rupiah string.
use Yadders\RupiahRedenom\Facades\Rupiah; $value = 12345.67; $formatted = Rupiah::format($value); // Returns "Rp 12.345,67" $simplifiedValue = Rupiah::simplifyRupiah(500000); // 500.0 $formattedSimplified = Rupiah::format($simplifiedValue); // Returns "Rp 500,00"
Testing
To run the package's tests, use the following command:
composer test
License
The MIT License (MIT). Please see License File for more information.