<?php

declare(strict_types=1);

namespace App\Support\Baselines;

enum BaselineSnapshotLifecycleState: string
{
    case Building = 'building';
    case Complete = 'complete';
    case Incomplete = 'incomplete';

    public function label(): string
    {
        return match ($this) {
            self::Building => 'Building',
            self::Complete => 'Complete',
            self::Incomplete => 'Incomplete',
        };
    }

    public function isConsumable(): bool
    {
        return $this === self::Complete;
    }

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

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