<?php

namespace goals\helpers;

enum goals_criteria_target_duration
{
    case ENTIRE_DURATION;
    case WEEKS;
    case MONTHS;
    case YEARS;

    public static function tryFrom(string $param): ?goals_criteria_target_duration
    {
        return match (strtoupper($param)) {
            'ENTIRE_DURATION' => goals_criteria_target_duration::ENTIRE_DURATION,
            'WEEKS' => goals_criteria_target_duration::WEEKS,
            'MONTHS' => goals_criteria_target_duration::MONTHS,
            'YEARS' => goals_criteria_target_duration::YEARS,
            default => null,
        };
    }

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