<?php

declare(strict_types=1);

namespace App\Enums;

/**
 * Kind of coverage held against an asset.
 *
 * An asset routinely carries more than one at a time — a manufacturer warranty
 * plus an AMC, sometimes an insurance policy — which is why coverage lives in
 * its own table rather than as start/end columns on `assets`.
 */
enum WarrantyType: string implements HasBadge
{
    case Manufacturer = 'manufacturer';
    case Extended = 'extended';
    case Amc = 'amc';
    case Insurance = 'insurance';

    /**
     * @return array<string, string> value => label, for select inputs
     */
    public static function options(): array
    {
        return array_reduce(
            self::cases(),
            static fn (array $carry, self $case): array => $carry + [$case->value => $case->label()],
            [],
        );
    }

    public function label(): string
    {
        return match ($this) {
            self::Manufacturer => 'Manufacturer Warranty',
            self::Extended => 'Extended Warranty',
            self::Amc => 'AMC',
            self::Insurance => 'Insurance',
        };
    }

    public function color(): string
    {
        return match ($this) {
            self::Manufacturer => 'primary',
            self::Extended => 'info',
            self::Amc => 'warning',
            self::Insurance => 'secondary',
        };
    }

    public function icon(): string
    {
        return match ($this) {
            self::Manufacturer => 'shield-check',
            self::Extended => 'shield-plus',
            self::Amc => 'wrench-adjustable',
            self::Insurance => 'umbrella',
        };
    }
}
