Laravel\Cashier\Cashier::formatAmount PHP Method

formatAmount() public static method

Format the given amount into a displayable currency.
public static formatAmount ( integer $amount ) : string
$amount integer
return string
    public static function formatAmount($amount)
    {
        if (static::$formatCurrencyUsing) {
            return call_user_func(static::$formatCurrencyUsing, $amount);
        }
        $amount = number_format($amount, 2);
        if (starts_with($amount, '-')) {
            return '-' . static::usesCurrencySymbol() . ltrim($amount, '-');
        } else {
            return static::usesCurrencySymbol() . $amount;
        }
    }

Usage Example

Example #1
0
 /**
  * Format the given amount into a string based on the user's preferences.
  *
  * @param  int  $amount
  * @return string
  */
 protected function formatAmount($amount)
 {
     return Cashier::formatAmount($amount);
 }