• 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.JSType</code>
11 */
12class JSType
13{
14    /**
15     * Use the default type.
16     *
17     * Generated from protobuf enum <code>JS_NORMAL = 0;</code>
18     */
19    const JS_NORMAL = 0;
20    /**
21     * Use JavaScript strings.
22     *
23     * Generated from protobuf enum <code>JS_STRING = 1;</code>
24     */
25    const JS_STRING = 1;
26    /**
27     * Use JavaScript numbers.
28     *
29     * Generated from protobuf enum <code>JS_NUMBER = 2;</code>
30     */
31    const JS_NUMBER = 2;
32
33    private static $valueToName = [
34        self::JS_NORMAL => 'JS_NORMAL',
35        self::JS_STRING => 'JS_STRING',
36        self::JS_NUMBER => 'JS_NUMBER',
37    ];
38
39    public static function name($value)
40    {
41        if (!isset(self::$valueToName[$value])) {
42            throw new UnexpectedValueException(sprintf(
43                    'Enum %s has no name defined for value %s', __CLASS__, $value));
44        }
45        return self::$valueToName[$value];
46    }
47
48
49    public static function value($name)
50    {
51        $const = __CLASS__ . '::' . strtoupper($name);
52        if (!defined($const)) {
53            throw new UnexpectedValueException(sprintf(
54                    'Enum %s has no value defined for name %s', __CLASS__, $name));
55        }
56        return constant($const);
57    }
58}
59
60// Adding a class alias for backwards compatibility with the previous class name.
61class_alias(JSType::class, \Google\Protobuf\Internal\FieldOptions_JSType::class);
62
63