<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/devtools/cloudtrace/v2/trace.proto

namespace Google\Cloud\Trace\V2\Span\TimeEvent\MessageEvent;

use UnexpectedValueException;

/**
 * Indicates whether the message was sent or received.
 *
 * Protobuf type <code>google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type</code>
 */
class Type
{
    /**
     * Unknown event type.
     *
     * Generated from protobuf enum <code>TYPE_UNSPECIFIED = 0;</code>
     */
    const TYPE_UNSPECIFIED = 0;
    /**
     * Indicates a sent message.
     *
     * Generated from protobuf enum <code>SENT = 1;</code>
     */
    const SENT = 1;
    /**
     * Indicates a received message.
     *
     * Generated from protobuf enum <code>RECEIVED = 2;</code>
     */
    const RECEIVED = 2;

    private static $valueToName = [
        self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED',
        self::SENT => 'SENT',
        self::RECEIVED => 'RECEIVED',
    ];

    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(Type::class, \Google\Cloud\Trace\V2\Span_TimeEvent_MessageEvent_Type::class);

