<?php

namespace modules\selfserve\helpers;

enum selfserve_lane_command
{
    case START; // command to start the lane
    case STOP; // command to stop the lane
    case RESET; // command to reset the lane
    case RESERVE; // command to reserve the lane
    case RELEASE; // command to release the lane (from reservation)

    public static function tryFrom(string $commandParam): ?selfserve_lane_command
    {
        return match (strtoupper($commandParam)) {
            'START' => selfserve_lane_command::START,
            'STOP' => selfserve_lane_command::STOP,
            'RESET' => selfserve_lane_command::RESET,
            'RESERVE' => selfserve_lane_command::RESERVE,
            'RELEASE' => selfserve_lane_command::RELEASE,
            default => null,
        };
    }

    public function equals(selfserve_lane_command $command): bool
    {
        return $this === $command;
    }
}
