<?php

declare(strict_types=1);

namespace App\Enums;

use App\Models\AdoptionApplication;
use App\Models\AssistanceApplication;
use App\Models\FosteringApplication;

enum FormType: string
{
    case Adoption = 'adoption';
    case Fostering = 'fostering';
    case Assistance = 'assistance';

    public function label(): string
    {
        return match ($this) {
            self::Adoption => 'Adoption',
            self::Fostering => 'Fostering',
            self::Assistance => 'Assistance',
        };
    }

    /**
     * Resolve the form type from an application model.
     */
    public static function fromApplication(AdoptionApplication|AssistanceApplication|FosteringApplication $application): self
    {
        return match (true) {
            $application instanceof AdoptionApplication => self::Adoption,
            $application instanceof FosteringApplication => self::Fostering,
            default => self::Assistance,
        };
    }
}
