<?php

namespace modules\subusers\helpers;

enum subusers_permission_node_key
{
    /** Vehicles */
    case VEHICLES_LIST;
    case VEHICLES_EDIT;
    case VEHICLES_DELETE;
    case VEHICLES_ADD;

    /** Self-Serve */
    case SELFSERVE_ADD;
    /** Bookings */
    case BOOKINGS_LIST;
    case BOOKINGS_EDIT;
    case BOOKINGS_DELETE;
    case BOOKINGS_ADD;
    /** Orders */
    case ORDERS_LIST;
    case ORDERS_EDIT;
    /** Subusers */
    case SUBUSERS_LIST;
    case SUBUSERS_EDIT;
    case SUBUSERS_DELETE;
    case SUBUSERS_ADD;

    public static function tryFrom(string $param): ?subusers_permission_node_key
    {
        return match (strtoupper($param)) {
            /** Vehicles */
            'VEHCILES_LIST' => subusers_permission_node_key::VEHICLES_LIST,
            'VEHCILES_EDIT' => subusers_permission_node_key::VEHICLES_EDIT,
            'VEHCILES_DELETE' => subusers_permission_node_key::VEHICLES_DELETE,
            'VEHCILES_ADD' => subusers_permission_node_key::VEHICLES_ADD,
            /** Self-Serve */
            'SELFSERVE_ADD' => subusers_permission_node_key::SELFSERVE_ADD,
            /** Bookings */
            'BOOKINGS_LIST' => subusers_permission_node_key::BOOKINGS_LIST,
            'BOOKINGS_EDIT' => subusers_permission_node_key::BOOKINGS_EDIT,
            'BOOKINGS_DELETE' => subusers_permission_node_key::BOOKINGS_DELETE,
            'BOOKINGS_ADD' => subusers_permission_node_key::BOOKINGS_ADD,
            /** Orders */
            'ORDERS_LIST' => subusers_permission_node_key::ORDERS_LIST,
            'ORDERS_EDIT' => subusers_permission_node_key::ORDERS_EDIT,
            /** Subusers */
            'SUBUSERS_LIST' => subusers_permission_node_key::SUBUSERS_LIST,
            'SUBUSERS_EDIT' => subusers_permission_node_key::SUBUSERS_EDIT,
            'SUBUSERS_DELETE' => subusers_permission_node_key::SUBUSERS_DELETE,
            'SUBUSERS_ADD' => subusers_permission_node_key::SUBUSERS_ADD,
            default => null,
        };
    }

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

}
