<?php

namespace goals\helpers;

enum goals_criteria_progress_alert_frequency
{
    case DAILY;   // Alert daily
    case WEEKLY;  // Alert weekly
    case MONTHLY; // Alert monthly
    case CHANGED; // Alert when there is a change
    case NONE;    // When there is no specific criteria

    public static function tryFrom(string $param): ?goals_criteria_progress_alert_frequency
    {
        return match (strtoupper($param)) {
            'DAILY' => goals_criteria_progress_alert_frequency::DAILY,
            'WEEKLY' => goals_criteria_progress_alert_frequency::WEEKLY,
            'MONTHLY' => goals_criteria_progress_alert_frequency::MONTHLY,
            'CHANGED' => goals_criteria_progress_alert_frequency::CHANGED,
            'NONE' => goals_criteria_progress_alert_frequency::NONE,
            default => null,
        };
    }

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