<?php

declare(strict_types=1);

namespace WPStack\Sandbox\Domain;

final class SessionState
{
    /**
     * @var array<string, list<string>>
     */
    private const TRANSITIONS = [
        'provisioning' => ['active', 'failed'],
        'active' => ['expired', 'replaced', 'deleted'],
        'expired' => ['deleted'],
        'replaced' => ['deleted'],
        'failed' => [],
        'deleted' => [],
    ];

    public static function canTransition(string $from, string $to): bool
    {
        return isset(self::TRANSITIONS[$from])
            && isset(self::TRANSITIONS[$to])
            && in_array($to, self::TRANSITIONS[$from], true);
    }
}
