Paul Yang | 77f64bb | 2017-10-05 21:03:57 -0700 | [diff] [blame] | 1 | <?php |
| 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! |
| 3 | # source: google/protobuf/type.proto |
| 4 | |
| 5 | namespace Google\Protobuf; |
| 6 | |
michaelbausor | 0b9af83 | 2018-11-28 16:44:53 -0800 | [diff] [blame] | 7 | use UnexpectedValueException; |
| 8 | |
Paul Yang | 77f64bb | 2017-10-05 21:03:57 -0700 | [diff] [blame] | 9 | /** |
| 10 | * The syntax in which a protocol buffer element is defined. |
| 11 | * |
Brent Shaffer | 6737954 | 2018-05-23 16:43:30 -0700 | [diff] [blame] | 12 | * Protobuf type <code>google.protobuf.Syntax</code> |
Paul Yang | 77f64bb | 2017-10-05 21:03:57 -0700 | [diff] [blame] | 13 | */ |
| 14 | class Syntax |
| 15 | { |
| 16 | /** |
| 17 | * Syntax `proto2`. |
| 18 | * |
| 19 | * Generated from protobuf enum <code>SYNTAX_PROTO2 = 0;</code> |
| 20 | */ |
| 21 | const SYNTAX_PROTO2 = 0; |
| 22 | /** |
| 23 | * Syntax `proto3`. |
| 24 | * |
| 25 | * Generated from protobuf enum <code>SYNTAX_PROTO3 = 1;</code> |
| 26 | */ |
| 27 | const SYNTAX_PROTO3 = 1; |
michaelbausor | 0b9af83 | 2018-11-28 16:44:53 -0800 | [diff] [blame] | 28 | |
| 29 | private static $valueToName = [ |
| 30 | self::SYNTAX_PROTO2 => 'SYNTAX_PROTO2', |
| 31 | self::SYNTAX_PROTO3 => 'SYNTAX_PROTO3', |
| 32 | ]; |
| 33 | |
| 34 | public static function name($value) |
| 35 | { |
| 36 | if (!isset(self::$valueToName[$value])) { |
| 37 | throw new UnexpectedValueException(sprintf( |
| 38 | 'Enum %s has no name defined for value %s', __CLASS__, $value)); |
| 39 | } |
| 40 | return self::$valueToName[$value]; |
| 41 | } |
| 42 | |
Joshua Haberman | a0eef68 | 2020-09-29 15:47:47 -0700 | [diff] [blame] | 43 | |
michaelbausor | 0b9af83 | 2018-11-28 16:44:53 -0800 | [diff] [blame] | 44 | public static function value($name) |
| 45 | { |
| 46 | $const = __CLASS__ . '::' . strtoupper($name); |
| 47 | if (!defined($const)) { |
| 48 | throw new UnexpectedValueException(sprintf( |
| 49 | 'Enum %s has no value defined for name %s', __CLASS__, $name)); |
| 50 | } |
| 51 | return constant($const); |
| 52 | } |
Paul Yang | 77f64bb | 2017-10-05 21:03:57 -0700 | [diff] [blame] | 53 | } |
| 54 | |