Kind.php 4.56 KB
Newer Older
1 2
<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
3
# source: google/protobuf/type.proto
4

5
namespace Google\Protobuf\Field;
6

7 8
use UnexpectedValueException;

9
/**
10 11 12
 * Basic field types.
 *
 * Protobuf type <code>google.protobuf.Field.Kind</code>
13
 */
14
class Kind
15 16
{
    /**
17 18 19 20 21 22 23
     * Field type unknown.
     *
     * Generated from protobuf enum <code>TYPE_UNKNOWN = 0;</code>
     */
    const TYPE_UNKNOWN = 0;
    /**
     * Field type double.
24
     *
25
     * Generated from protobuf enum <code>TYPE_DOUBLE = 1;</code>
26 27 28
     */
    const TYPE_DOUBLE = 1;
    /**
29 30
     * Field type float.
     *
31
     * Generated from protobuf enum <code>TYPE_FLOAT = 2;</code>
32 33 34
     */
    const TYPE_FLOAT = 2;
    /**
35
     * Field type int64.
36
     *
37
     * Generated from protobuf enum <code>TYPE_INT64 = 3;</code>
38 39 40
     */
    const TYPE_INT64 = 3;
    /**
41 42
     * Field type uint64.
     *
43
     * Generated from protobuf enum <code>TYPE_UINT64 = 4;</code>
44 45 46
     */
    const TYPE_UINT64 = 4;
    /**
47
     * Field type int32.
48
     *
49
     * Generated from protobuf enum <code>TYPE_INT32 = 5;</code>
50 51 52
     */
    const TYPE_INT32 = 5;
    /**
53 54
     * Field type fixed64.
     *
55
     * Generated from protobuf enum <code>TYPE_FIXED64 = 6;</code>
56 57 58
     */
    const TYPE_FIXED64 = 6;
    /**
59 60
     * Field type fixed32.
     *
61
     * Generated from protobuf enum <code>TYPE_FIXED32 = 7;</code>
62 63 64
     */
    const TYPE_FIXED32 = 7;
    /**
65 66
     * Field type bool.
     *
67
     * Generated from protobuf enum <code>TYPE_BOOL = 8;</code>
68 69 70
     */
    const TYPE_BOOL = 8;
    /**
71 72
     * Field type string.
     *
73
     * Generated from protobuf enum <code>TYPE_STRING = 9;</code>
74 75 76
     */
    const TYPE_STRING = 9;
    /**
77
     * Field type group. Proto2 syntax only, and deprecated.
78
     *
79
     * Generated from protobuf enum <code>TYPE_GROUP = 10;</code>
80 81 82
     */
    const TYPE_GROUP = 10;
    /**
83
     * Field type message.
84
     *
85
     * Generated from protobuf enum <code>TYPE_MESSAGE = 11;</code>
86 87 88
     */
    const TYPE_MESSAGE = 11;
    /**
89
     * Field type bytes.
90
     *
91
     * Generated from protobuf enum <code>TYPE_BYTES = 12;</code>
92 93 94
     */
    const TYPE_BYTES = 12;
    /**
95 96
     * Field type uint32.
     *
97
     * Generated from protobuf enum <code>TYPE_UINT32 = 13;</code>
98 99 100
     */
    const TYPE_UINT32 = 13;
    /**
101 102
     * Field type enum.
     *
103
     * Generated from protobuf enum <code>TYPE_ENUM = 14;</code>
104 105 106
     */
    const TYPE_ENUM = 14;
    /**
107 108
     * Field type sfixed32.
     *
109
     * Generated from protobuf enum <code>TYPE_SFIXED32 = 15;</code>
110 111 112
     */
    const TYPE_SFIXED32 = 15;
    /**
113 114
     * Field type sfixed64.
     *
115
     * Generated from protobuf enum <code>TYPE_SFIXED64 = 16;</code>
116 117 118
     */
    const TYPE_SFIXED64 = 16;
    /**
119
     * Field type sint32.
120
     *
121
     * Generated from protobuf enum <code>TYPE_SINT32 = 17;</code>
122 123 124
     */
    const TYPE_SINT32 = 17;
    /**
125
     * Field type sint64.
126
     *
127
     * Generated from protobuf enum <code>TYPE_SINT64 = 18;</code>
128 129
     */
    const TYPE_SINT64 = 18;
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170

    private static $valueToName = [
        self::TYPE_UNKNOWN => 'TYPE_UNKNOWN',
        self::TYPE_DOUBLE => 'TYPE_DOUBLE',
        self::TYPE_FLOAT => 'TYPE_FLOAT',
        self::TYPE_INT64 => 'TYPE_INT64',
        self::TYPE_UINT64 => 'TYPE_UINT64',
        self::TYPE_INT32 => 'TYPE_INT32',
        self::TYPE_FIXED64 => 'TYPE_FIXED64',
        self::TYPE_FIXED32 => 'TYPE_FIXED32',
        self::TYPE_BOOL => 'TYPE_BOOL',
        self::TYPE_STRING => 'TYPE_STRING',
        self::TYPE_GROUP => 'TYPE_GROUP',
        self::TYPE_MESSAGE => 'TYPE_MESSAGE',
        self::TYPE_BYTES => 'TYPE_BYTES',
        self::TYPE_UINT32 => 'TYPE_UINT32',
        self::TYPE_ENUM => 'TYPE_ENUM',
        self::TYPE_SFIXED32 => 'TYPE_SFIXED32',
        self::TYPE_SFIXED64 => 'TYPE_SFIXED64',
        self::TYPE_SINT32 => 'TYPE_SINT32',
        self::TYPE_SINT64 => 'TYPE_SINT64',
    ];

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

173 174 175
// Adding a class alias for backwards compatibility with the previous class name.
class_alias(Kind::class, \Google\Protobuf\Field_Kind::class);