<?php
 
 
 

namespace PhpWA\Protocol\Proto\Message\PeerDataOperationRequestResponseMessage\PeerDataOperationResult;

use UnexpectedValueException;




class HistorySyncChunkRetryResponseCode
{
    


    const HISTORY_SYNC_CHUNK_RETRY_RESPONSE_CODE_UNSPECIFIED = 0;
    


    const GENERATION_ERROR = 1;
    


    const CHUNK_CONSUMED = 2;
    


    const TIMEOUT = 3;
    


    const SESSION_EXHAUSTED = 4;
    


    const CHUNK_EXHAUSTED = 5;
    


    const DUPLICATED_REQUEST = 6;

    private static $valueToName = [
        self::HISTORY_SYNC_CHUNK_RETRY_RESPONSE_CODE_UNSPECIFIED => 'HISTORY_SYNC_CHUNK_RETRY_RESPONSE_CODE_UNSPECIFIED',
        self::GENERATION_ERROR => 'GENERATION_ERROR',
        self::CHUNK_CONSUMED => 'CHUNK_CONSUMED',
        self::TIMEOUT => 'TIMEOUT',
        self::SESSION_EXHAUSTED => 'SESSION_EXHAUSTED',
        self::CHUNK_EXHAUSTED => 'CHUNK_EXHAUSTED',
        self::DUPLICATED_REQUEST => 'DUPLICATED_REQUEST',
    ];

    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);
    }
}

