mapWithKeys(function ($estimate) use ($currency) { // Format usage $usage = match ($estimate['feature']) { 'bandwidth' => Metric::megabytes($estimate['usage'])->format(), 'storage' => Metric::megabytes($estimate['usage'])->format(), }; // Normalize units $amount = $estimate['amount'] / 1000; return [ $estimate['feature'] => [ 'feature' => $estimate['feature'], 'amount' => $amount, 'cost' => format_currency($amount, $currency), 'usage' => $usage, ] ]; }); } }