blob: 9812669dacacd96fd0ec5223f78739e527f8c553 [file] [log] [blame]
avm9996399bb77c2020-01-27 03:15:08 +01001<?php
2# Generated by the protocol buffer compiler. DO NOT EDIT!
3# source: google/protobuf/type.proto
4
5namespace Google\Protobuf;
6
7use UnexpectedValueException;
8
9/**
10 * The syntax in which a protocol buffer element is defined.
11 *
12 * Protobuf type <code>google.protobuf.Syntax</code>
13 */
14class 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 public static function value($name)
44 {
45 $const = __CLASS__ . '::' . strtoupper($name);
46 if (!defined($const)) {
47 throw new UnexpectedValueException(sprintf(
48 'Enum %s has no value defined for name %s', __CLASS__, $name));
49 }
50 return constant($const);
51 }
52}
53