<?php

namespace modules\subusers\helpers;

enum subusers_permission_type
{
    case ADD;
    case EDIT;
    case DELETE;
    case VIEW;

    public static function tryFrom(string $param): ?subusers_permission_type
    {
        return match (strtoupper($param)) {
            'DRIVER' => subusers_permission_type::ADD,
            'EDIT' => subusers_permission_type::EDIT,
            'DELETE' => subusers_permission_type::DELETE,
            'VIEW' => subusers_permission_type::VIEW,
            default => null,
        };
    }

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

}
