Debian Codegraph @

php/src/Google/Protobuf/Syntax.php

raw
1 <?php
2 # Generated by the protocol buffer compiler. DO NOT EDIT!
3 # source: google/protobuf/type.proto
4
5 namespace Google\Protobuf;
6
7 use UnexpectedValueException;
8
9 /**
10 * The syntax in which a protocol buffer element is defined.
11 *
12 * Protobuf type <code>google.protobuf.Syntax</code>
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;
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
43
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 }
53 }
54