• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?php
2# Generated by the protocol buffer compiler.  DO NOT EDIT!
3# source: google/protobuf/descriptor.proto
4
5namespace Google\Protobuf\Internal\FieldOptions;
6
7use UnexpectedValueException;
8
9/**
10 * Protobuf type <code>google.protobuf.FieldOptions.CType</code>
11 */
12class CType
13{
14    /**
15     * Default mode.
16     *
17     * Generated from protobuf enum <code>STRING = 0;</code>
18     */
19    const STRING = 0;
20    /**
21     * Generated from protobuf enum <code>CORD = 1;</code>
22     */
23    const CORD = 1;
24    /**
25     * Generated from protobuf enum <code>STRING_PIECE = 2;</code>
26     */
27    const STRING_PIECE = 2;
28
29    private static $valueToName = [
30        self::STRING => 'STRING',
31        self::CORD => 'CORD',
32        self::STRING_PIECE => 'STRING_PIECE',
33    ];
34
35    public static function name($value)
36    {
37        if (!isset(self::$valueToName[$value])) {
38            throw new UnexpectedValueException(sprintf(
39                    'Enum %s has no name defined for value %s', __CLASS__, $value));
40        }
41        return self::$valueToName[$value];
42    }
43
44
45    public static function value($name)
46    {
47        $const = __CLASS__ . '::' . strtoupper($name);
48        if (!defined($const)) {
49            throw new UnexpectedValueException(sprintf(
50                    'Enum %s has no value defined for name %s', __CLASS__, $name));
51        }
52        return constant($const);
53    }
54}
55
56// Adding a class alias for backwards compatibility with the previous class name.
57class_alias(CType::class, \Google\Protobuf\Internal\FieldOptions_CType::class);
58
59