<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: apache/rocketmq/v2/definition.proto

namespace Apache\Rocketmq\V2;

use UnexpectedValueException;

/**
 * Protobuf type <code>apache.rocketmq.v2.DigestType</code>
 */
class DigestType
{
    /**
     * Generated from protobuf enum <code>DIGEST_TYPE_UNSPECIFIED = 0;</code>
     */
    const DIGEST_TYPE_UNSPECIFIED = 0;
    /**
     * CRC algorithm achieves goal of detecting random data error with lowest
     * computation overhead.
     *
     * Generated from protobuf enum <code>CRC32 = 1;</code>
     */
    const CRC32 = 1;
    /**
     * MD5 algorithm achieves good balance between collision rate and computation
     * overhead.
     *
     * Generated from protobuf enum <code>MD5 = 2;</code>
     */
    const MD5 = 2;
    /**
     * SHA-family has substantially fewer collision with fair amount of
     * computation.
     *
     * Generated from protobuf enum <code>SHA1 = 3;</code>
     */
    const SHA1 = 3;

    private static $valueToName = [
        self::DIGEST_TYPE_UNSPECIFIED => 'DIGEST_TYPE_UNSPECIFIED',
        self::CRC32 => 'CRC32',
        self::MD5 => 'MD5',
        self::SHA1 => 'SHA1',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

