add money formatter helper

This commit is contained in:
hackerESQ
2024-08-10 13:30:03 -05:00
parent 4377aee9e5
commit a7acb2f346
3 changed files with 25 additions and 17 deletions
+15
View File
@@ -0,0 +1,15 @@
<?php
if (!function_exists('formatMoney')) {
/**
* Returns a formatted string for currency
*
* @param int|float $amount
*
* */
function formatMoney(int|float $amount) {
$formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
return $formatter->formatCurrency((float) $amount, 'USD');
}
}