<?php

namespace App\Support\Badges\Domains;

use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeMapper;
use App\Support\Badges\BadgeSpec;

final class BooleanHasErrorsBadge implements BadgeMapper
{
    public function spec(mixed $value): BadgeSpec
    {
        $state = BadgeCatalog::normalizeState($value);

        return match ($state) {
            'true', '1', 'yes', 'errors' => new BadgeSpec('Errors', 'danger', 'heroicon-m-x-circle'),
            'false', '0', 'no' => new BadgeSpec('No errors', 'success', 'heroicon-m-check-circle'),
            default => BadgeSpec::unknown(),
        };
    }
}
