<?php

namespace App\Core\Traits;

trait FormatsMoney
{
    public function formatMoney(float $amount, string $currency = 'NGN'): string
    {
        return $currency . ' ' . number_format($amount, 2);
    }

    public function formatMoneyShort(float $amount): string
    {
        if ($amount >= 1_000_000) {
            return round($amount / 1_000_000, 1) . 'M';
        }

        if ($amount >= 1_000) {
            return round($amount / 1_000, 1) . 'K';
        }

        return number_format($amount, 2);
    }
}
