<?php

declare(strict_types=1);

namespace App\Support\Onboarding;

enum OnboardingLifecycleState: string
{
    case Draft = 'draft';
    case Verifying = 'verifying';
    case ActionRequired = 'action_required';
    case Bootstrapping = 'bootstrapping';
    case ReadyForActivation = 'ready_for_activation';
    case Completed = 'completed';
    case Cancelled = 'cancelled';

    public function label(): string
    {
        return match ($this) {
            self::Draft => 'Draft',
            self::Verifying => 'Verifying',
            self::ActionRequired => 'Action required',
            self::Bootstrapping => 'Bootstrapping',
            self::ReadyForActivation => 'Ready for activation',
            self::Completed => 'Completed',
            self::Cancelled => 'Cancelled',
        };
    }

    public function isTerminal(): bool
    {
        return in_array($this, [self::Completed, self::Cancelled], true);
    }

    /**
     * @return array<int, string>
     */
    public static function values(): array
    {
        return array_map(
            static fn (self $case): string => $case->value,
            self::cases(),
        );
    }
}
