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

namespace Couchbase\Protostellar\Generated\KV\V1\MutateInRequest\Spec;

use UnexpectedValueException;

/**
 * Protobuf type <code>couchbase.kv.v1.MutateInRequest.Spec.Operation</code>
 */
class Operation
{
    /**
     * Generated from protobuf enum <code>OPERATION_INSERT = 0;</code>
     */
    const OPERATION_INSERT = 0;
    /**
     * Generated from protobuf enum <code>OPERATION_UPSERT = 1;</code>
     */
    const OPERATION_UPSERT = 1;
    /**
     * Generated from protobuf enum <code>OPERATION_REPLACE = 2;</code>
     */
    const OPERATION_REPLACE = 2;
    /**
     * Generated from protobuf enum <code>OPERATION_REMOVE = 3;</code>
     */
    const OPERATION_REMOVE = 3;
    /**
     * Generated from protobuf enum <code>OPERATION_ARRAY_APPEND = 4;</code>
     */
    const OPERATION_ARRAY_APPEND = 4;
    /**
     * Generated from protobuf enum <code>OPERATION_ARRAY_PREPEND = 5;</code>
     */
    const OPERATION_ARRAY_PREPEND = 5;
    /**
     * Generated from protobuf enum <code>OPERATION_ARRAY_INSERT = 6;</code>
     */
    const OPERATION_ARRAY_INSERT = 6;
    /**
     * Generated from protobuf enum <code>OPERATION_ARRAY_ADD_UNIQUE = 7;</code>
     */
    const OPERATION_ARRAY_ADD_UNIQUE = 7;
    /**
     * Generated from protobuf enum <code>OPERATION_COUNTER = 8;</code>
     */
    const OPERATION_COUNTER = 8;

    private static $valueToName = [
        self::OPERATION_INSERT => 'OPERATION_INSERT',
        self::OPERATION_UPSERT => 'OPERATION_UPSERT',
        self::OPERATION_REPLACE => 'OPERATION_REPLACE',
        self::OPERATION_REMOVE => 'OPERATION_REMOVE',
        self::OPERATION_ARRAY_APPEND => 'OPERATION_ARRAY_APPEND',
        self::OPERATION_ARRAY_PREPEND => 'OPERATION_ARRAY_PREPEND',
        self::OPERATION_ARRAY_INSERT => 'OPERATION_ARRAY_INSERT',
        self::OPERATION_ARRAY_ADD_UNIQUE => 'OPERATION_ARRAY_ADD_UNIQUE',
        self::OPERATION_COUNTER => 'OPERATION_COUNTER',
    ];

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

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(Operation::class, \Couchbase\Protostellar\Generated\KV\V1\MutateInRequest_Spec_Operation::class);

