<?php

namespace App\Enums;

enum AppointmentStatus: string
{
    case CONFIRMED = 'confirmed';
    case CHECKED_IN = 'checked_in';
    case WAITING = 'waiting';
    case WITH_DOCTOR = 'with_doctor';
    case COMPLETED = 'completed';
    case CANCELLED = 'cancelled';
    case NO_SHOW = 'no_show';

    public function allowedNext(): array
    {
        return match ($this) {
            self::CONFIRMED => [self::CHECKED_IN, self::CANCELLED, self::NO_SHOW],
            self::CHECKED_IN => [self::WAITING, self::CANCELLED, self::NO_SHOW],
            self::WAITING => [self::WITH_DOCTOR, self::CANCELLED, self::NO_SHOW],
            self::WITH_DOCTOR => [self::COMPLETED, self::WAITING],
            self::COMPLETED, self::CANCELLED, self::NO_SHOW => [],
        };
    }

    public function blocksAvailability(): bool
    {
        return ! in_array($this, [self::CANCELLED, self::NO_SHOW], true);
    }
}
