<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/devtools/build/v1/build_events.proto

namespace Google\Cloud\Build\V1\BuildEvent\BuildComponentStreamFinished;

use UnexpectedValueException;

/**
 * How did the event stream finish.
 *
 * Protobuf type <code>google.devtools.build.v1.BuildEvent.BuildComponentStreamFinished.FinishType</code>
 */
class FinishType
{
    /**
     * Unknown or unspecified; callers should never set this value.
     *
     * Generated from protobuf enum <code>FINISH_TYPE_UNSPECIFIED = 0;</code>
     */
    const FINISH_TYPE_UNSPECIFIED = 0;
    /**
     * Set by the event publisher to indicate a build event stream is
     * finished.
     *
     * Generated from protobuf enum <code>FINISHED = 1;</code>
     */
    const FINISHED = 1;
    /**
     * Set by the WatchBuild RPC server when the publisher of a build event
     * stream stops publishing events without publishing a
     * BuildComponentStreamFinished event whose type equals FINISHED.
     *
     * Generated from protobuf enum <code>EXPIRED = 2;</code>
     */
    const EXPIRED = 2;

    private static $valueToName = [
        self::FINISH_TYPE_UNSPECIFIED => 'FINISH_TYPE_UNSPECIFIED',
        self::FINISHED => 'FINISHED',
        self::EXPIRED => 'EXPIRED',
    ];

    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(FinishType::class, \Google\Cloud\Build\V1\BuildEvent_BuildComponentStreamFinished_FinishType::class);

