blob: 10952bfd42ceadb9790e3621d138376f01bb52c3 [file] [log] [blame]
Paul Yang77f64bb2017-10-05 21:03:57 -07001<?php
2# Generated by the protocol buffer compiler. DO NOT EDIT!
3# source: google/protobuf/type.proto
4
5namespace Google\Protobuf;
6
michaelbausor0b9af832018-11-28 16:44:53 -08007use UnexpectedValueException;
8
Paul Yang77f64bb2017-10-05 21:03:57 -07009/**
10 * The syntax in which a protocol buffer element is defined.
11 *
Brent Shaffer67379542018-05-23 16:43:30 -070012 * Protobuf type <code>google.protobuf.Syntax</code>
Paul Yang77f64bb2017-10-05 21:03:57 -070013 */
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;
michaelbausor0b9af832018-11-28 16:44:53 -080028
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 Habermana0eef682020-09-29 15:47:47 -070043
michaelbausor0b9af832018-11-28 16:44:53 -080044 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 Yang77f64bb2017-10-05 21:03:57 -070053}
54