Common\Core\Twig\Extensions\BaseTwigModifiers::formatCurrency PHP Method

formatCurrency() public static method

Format a number as currency syntax: {{ $string|formatcurrency($currency, $decimals) }}.
public static formatCurrency ( string $string, string $currency = 'EUR', integer $decimals = null ) : string
$string string The string to form.
$currency string The currency to will be used to format the number.
$decimals integer The number of decimals to show.
return string
    public static function formatCurrency($string, $currency = 'EUR', $decimals = null)
    {
        $decimals = $decimals === null ? 2 : (int) $decimals;
        // @later get settings from backend
        switch ($currency) {
            case 'EUR':
                $currency = '€';
                break;
            default:
        }
        return $currency . ' ' . static::formatNumber($string, $decimals);
    }