<?php

namespace goals\helpers;

enum goals_criteria_type
{
    case PRODUCT; // When the goal is related to a product
    case REVENUE;  // When the goal is related to revenue
    case VISITS;   // When the goal is related to visits
    case NONE;    // When there is no specific criteria

    public static function tryFrom(string $param): ?goals_criteria_type
    {
        return match (strtoupper($param)) {
            'PRODUCT' => goals_criteria_type::PRODUCT,
            'REVENUE' => goals_criteria_type::REVENUE,
            'VISITS' => goals_criteria_type::VISITS,
            'NONE' => goals_criteria_type::NONE,
            default => null,
        };
    }

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