<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: core/Tron.proto

namespace Protocol;

use UnexpectedValueException;

/**
 * Protobuf type <code>protocol.ReasonCode</code>
 */
class ReasonCode
{
    /**
     * Generated from protobuf enum <code>REQUESTED = 0;</code>
     */
    const REQUESTED = 0;
    /**
     * Generated from protobuf enum <code>BAD_PROTOCOL = 2;</code>
     */
    const BAD_PROTOCOL = 2;
    /**
     * Generated from protobuf enum <code>TOO_MANY_PEERS = 4;</code>
     */
    const TOO_MANY_PEERS = 4;
    /**
     * Generated from protobuf enum <code>DUPLICATE_PEER = 5;</code>
     */
    const DUPLICATE_PEER = 5;
    /**
     * Generated from protobuf enum <code>INCOMPATIBLE_PROTOCOL = 6;</code>
     */
    const INCOMPATIBLE_PROTOCOL = 6;
    /**
     * Generated from protobuf enum <code>NULL_IDENTITY = 7;</code>
     */
    const NULL_IDENTITY = 7;
    /**
     * Generated from protobuf enum <code>PEER_QUITING = 8;</code>
     */
    const PEER_QUITING = 8;
    /**
     * Generated from protobuf enum <code>UNEXPECTED_IDENTITY = 9;</code>
     */
    const UNEXPECTED_IDENTITY = 9;
    /**
     * Generated from protobuf enum <code>LOCAL_IDENTITY = 10;</code>
     */
    const LOCAL_IDENTITY = 10;
    /**
     * Generated from protobuf enum <code>PING_TIMEOUT = 11;</code>
     */
    const PING_TIMEOUT = 11;
    /**
     * Generated from protobuf enum <code>USER_REASON = 16;</code>
     */
    const USER_REASON = 16;
    /**
     * Generated from protobuf enum <code>RESET = 17;</code>
     */
    const RESET = 17;
    /**
     * Generated from protobuf enum <code>SYNC_FAIL = 18;</code>
     */
    const SYNC_FAIL = 18;
    /**
     * Generated from protobuf enum <code>FETCH_FAIL = 19;</code>
     */
    const FETCH_FAIL = 19;
    /**
     * Generated from protobuf enum <code>BAD_TX = 20;</code>
     */
    const BAD_TX = 20;
    /**
     * Generated from protobuf enum <code>BAD_BLOCK = 21;</code>
     */
    const BAD_BLOCK = 21;
    /**
     * Generated from protobuf enum <code>FORKED = 22;</code>
     */
    const FORKED = 22;
    /**
     * Generated from protobuf enum <code>UNLINKABLE = 23;</code>
     */
    const UNLINKABLE = 23;
    /**
     * Generated from protobuf enum <code>INCOMPATIBLE_VERSION = 24;</code>
     */
    const INCOMPATIBLE_VERSION = 24;
    /**
     * Generated from protobuf enum <code>INCOMPATIBLE_CHAIN = 25;</code>
     */
    const INCOMPATIBLE_CHAIN = 25;
    /**
     * Generated from protobuf enum <code>TIME_OUT = 32;</code>
     */
    const TIME_OUT = 32;
    /**
     * Generated from protobuf enum <code>CONNECT_FAIL = 33;</code>
     */
    const CONNECT_FAIL = 33;
    /**
     * Generated from protobuf enum <code>TOO_MANY_PEERS_WITH_SAME_IP = 34;</code>
     */
    const TOO_MANY_PEERS_WITH_SAME_IP = 34;
    /**
     * Generated from protobuf enum <code>UNKNOWN = 255;</code>
     */
    const UNKNOWN = 255;

    private static $valueToName = [
        self::REQUESTED => 'REQUESTED',
        self::BAD_PROTOCOL => 'BAD_PROTOCOL',
        self::TOO_MANY_PEERS => 'TOO_MANY_PEERS',
        self::DUPLICATE_PEER => 'DUPLICATE_PEER',
        self::INCOMPATIBLE_PROTOCOL => 'INCOMPATIBLE_PROTOCOL',
        self::NULL_IDENTITY => 'NULL_IDENTITY',
        self::PEER_QUITING => 'PEER_QUITING',
        self::UNEXPECTED_IDENTITY => 'UNEXPECTED_IDENTITY',
        self::LOCAL_IDENTITY => 'LOCAL_IDENTITY',
        self::PING_TIMEOUT => 'PING_TIMEOUT',
        self::USER_REASON => 'USER_REASON',
        self::RESET => 'RESET',
        self::SYNC_FAIL => 'SYNC_FAIL',
        self::FETCH_FAIL => 'FETCH_FAIL',
        self::BAD_TX => 'BAD_TX',
        self::BAD_BLOCK => 'BAD_BLOCK',
        self::FORKED => 'FORKED',
        self::UNLINKABLE => 'UNLINKABLE',
        self::INCOMPATIBLE_VERSION => 'INCOMPATIBLE_VERSION',
        self::INCOMPATIBLE_CHAIN => 'INCOMPATIBLE_CHAIN',
        self::TIME_OUT => 'TIME_OUT',
        self::CONNECT_FAIL => 'CONNECT_FAIL',
        self::TOO_MANY_PEERS_WITH_SAME_IP => 'TOO_MANY_PEERS_WITH_SAME_IP',
        self::UNKNOWN => 'UNKNOWN',
    ];

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

