diff --git a/core/lib/Thelia/Tools/MoneyFormat.php b/core/lib/Thelia/Tools/MoneyFormat.php new file mode 100644 index 000000000..94239907c --- /dev/null +++ b/core/lib/Thelia/Tools/MoneyFormat.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tools; + +use Symfony\Component\HttpFoundation\Request; + +class MoneyFormat extends NumberFormat +{ + public static function getInstance(Request $request) + { + return new MoneyFormat($request); + } + + /** + * Get a standard number, with '.' as decimal point no thousands separator, and no currency symbol + * so that this number can be used to perform calculations. + * + * @param float $number the number + * @param string $decimals number of decimal figures + */ + public function formatStandardMoney($number, $decimals = null) + { + return parent::formatStandardNumber($number, $decimals); + } + + public function format($number, $decimals = null, $decPoint = null, $thousandsSep = null, $symbol = null) + { + $number = parent::format($number, $decimals, $decPoint, $thousandsSep); + + if ($symbol !== null) { + // FIXME: should be a parameter related to i18n configuration + $number = $number . ' ' . $symbol; + } + return $number; + } +}