<?php

namespace App\Domain\Attendance\Enums;

enum AttendanceStatus: string
{
    case Expected = 'expected';
    case Present = 'present';
    case Late = 'late';
    case Excused = 'excused';
    case Absent = 'absent';
    case NoShow = 'no_show';
    case LeftEarly = 'left_early';
    case Partial = 'partial';
    case Cancelled = 'cancelled';
    case Exempt = 'exempt';

    public function label(): string
    {
        return match ($this) {
            self::Expected => 'متوقع',
            self::Present => 'حاضر',
            self::Late => 'متأخر',
            self::Excused => 'معذور',
            self::Absent => 'غائب',
            self::NoShow => 'لم يحضر',
            self::LeftEarly => 'غادر مبكراً',
            self::Partial => 'حضور جزئي',
            self::Cancelled => 'ملغى',
            self::Exempt => 'معفى',
        };
    }

    public function isPositive(): bool
    {
        return in_array($this, [self::Present, self::Late, self::Partial]);
    }

    public function isNegative(): bool
    {
        return in_array($this, [self::Absent, self::NoShow]);
    }

    public function isExcluded(): bool
    {
        return in_array($this, [self::Cancelled, self::Exempt]);
    }

    public function color(): string
    {
        return match ($this) {
            self::Expected => 'gray',
            self::Present => 'green',
            self::Late => 'amber',
            self::Excused => 'blue',
            self::Absent => 'red',
            self::NoShow => 'red',
            self::LeftEarly => 'orange',
            self::Partial => 'yellow',
            self::Cancelled => 'gray',
            self::Exempt => 'purple',
        };
    }
}
