<?php

namespace goals\helpers;

enum goals_criteria_progress_alert_progress_type
{
    case ALL; // Shows the goal, percentage and count of the goal
    case PERCENTAGE_ONLY;       // Shows only the percentage of the goal
    case COUNT_ONLY; // Shows only the count of the goal
    case COUNT_AND_TARGET; // Shows the count and target of the goal
    case NONE;    // When there is no specific criteria

    public static function tryFrom(string $param): ?goals_criteria_progress_alert_progress_type
    {
        return match (strtoupper($param)) {
            'ALL' => goals_criteria_progress_alert_progress_type::ALL,
            'PERCENTAGE_ONLY' => goals_criteria_progress_alert_progress_type::PERCENTAGE_ONLY,
            'COUNT_ONLY' => goals_criteria_progress_alert_progress_type::COUNT_ONLY,
            'COUNT_AND_TARGET' => goals_criteria_progress_alert_progress_type::COUNT_AND_TARGET,
            'NONE' => goals_criteria_progress_alert_progress_type::NONE,
            default => null,
        };
    }

    public function equals(goals_criteria_progress_alert_progress_type $param): bool
    {
        return $this === $param;
    }
}
