<?php

namespace App\Enums;

enum QualificationType: string
{
    case Uce = 'uce';
    case Uace = 'uace';
    case Diploma = 'diploma';
    case Certificate = 'certificate';
    case Degree = 'degree';
    case Other = 'other';

    public function label(): string
    {
        return match ($this) {
            self::Uce => 'UCE (O-Level)',
            self::Uace => 'UACE (A-Level)',
            self::Diploma => 'Diploma',
            self::Certificate => 'Certificate',
            self::Degree => 'Degree',
            self::Other => 'Other Qualification',
        };
    }

    /** Whether this qualification captures subject/grade rows. */
    public function hasSubjects(): bool
    {
        return in_array($this, [self::Uce, self::Uace], true);
    }

    /** Whether this qualification captures a GPA/class of award. */
    public function hasGpa(): bool
    {
        return in_array($this, [self::Diploma, self::Degree], true);
    }

    public function requiresIndexNumber(): bool
    {
        return in_array($this, [self::Uce, self::Uace], true);
    }

    public static function options(): array
    {
        return array_map(fn (self $c) => ['value' => $c->value, 'label' => $c->label()], self::cases());
    }
}
