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

namespace Google\Cloud\Trace\V2\Span\Link;

use UnexpectedValueException;

/**
 * The relationship of the current span relative to the linked span: child,
 * parent, or unspecified.
 *
 * Protobuf type <code>google.devtools.cloudtrace.v2.Span.Link.Type</code>
 */
class Type
{
    /**
     * The relationship of the two spans is unknown.
     *
     * Generated from protobuf enum <code>TYPE_UNSPECIFIED = 0;</code>
     */
    const TYPE_UNSPECIFIED = 0;
    /**
     * The linked span is a child of the current span.
     *
     * Generated from protobuf enum <code>CHILD_LINKED_SPAN = 1;</code>
     */
    const CHILD_LINKED_SPAN = 1;
    /**
     * The linked span is a parent of the current span.
     *
     * Generated from protobuf enum <code>PARENT_LINKED_SPAN = 2;</code>
     */
    const PARENT_LINKED_SPAN = 2;

    private static $valueToName = [
        self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED',
        self::CHILD_LINKED_SPAN => 'CHILD_LINKED_SPAN',
        self::PARENT_LINKED_SPAN => 'PARENT_LINKED_SPAN',
    ];

    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_Link_Type::class);

