<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: couchbase/kv/v1/kv.proto

namespace Couchbase\Protostellar\Generated\KV\V1;

use UnexpectedValueException;

/**
 * Protobuf type <code>couchbase.kv.v1.DurabilityLevel</code>
 */
class DurabilityLevel
{
    /**
     * Generated from protobuf enum <code>DURABILITY_LEVEL_MAJORITY = 0;</code>
     */
    const DURABILITY_LEVEL_MAJORITY = 0;
    /**
     * Generated from protobuf enum <code>DURABILITY_LEVEL_MAJORITY_AND_PERSIST_TO_ACTIVE = 1;</code>
     */
    const DURABILITY_LEVEL_MAJORITY_AND_PERSIST_TO_ACTIVE = 1;
    /**
     * Generated from protobuf enum <code>DURABILITY_LEVEL_PERSIST_TO_MAJORITY = 2;</code>
     */
    const DURABILITY_LEVEL_PERSIST_TO_MAJORITY = 2;

    private static $valueToName = [
        self::DURABILITY_LEVEL_MAJORITY => 'DURABILITY_LEVEL_MAJORITY',
        self::DURABILITY_LEVEL_MAJORITY_AND_PERSIST_TO_ACTIVE => 'DURABILITY_LEVEL_MAJORITY_AND_PERSIST_TO_ACTIVE',
        self::DURABILITY_LEVEL_PERSIST_TO_MAJORITY => 'DURABILITY_LEVEL_PERSIST_TO_MAJORITY',
    ];

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

