<?php

namespace App\Modules\Dashboard\Services;

use Illuminate\Support\Facades\Lang;

class DashboardStatLabeler
{
    /**
     * @param  list<array{key: string, value: int, icon: string}>  $metrics
     * @return list<array{key: string, label: string, value: int|string, icon: string}>
     */
    public function label(array $metrics): array
    {
        $out = [];
        foreach ($metrics as $m) {
            $labelKey = 'dashboard.stats.keys.'.$m['key'];
            $out[] = [
                'key' => $m['key'],
                'label' => (string) (Lang::has($labelKey) ? __($labelKey) : $m['key']),
                'value' => $m['value'],
                'icon' => $m['icon'],
            ];
        }

        return $out;
    }
}
