1ffe3c632Sopenharmony_ci<?php
2ffe3c632Sopenharmony_ci# Generated by the protocol buffer compiler.  DO NOT EDIT!
3ffe3c632Sopenharmony_ci# source: google/protobuf/type.proto
4ffe3c632Sopenharmony_ci
5ffe3c632Sopenharmony_cinamespace Google\Protobuf\Field;
6ffe3c632Sopenharmony_ci
7ffe3c632Sopenharmony_ciuse UnexpectedValueException;
8ffe3c632Sopenharmony_ci
9ffe3c632Sopenharmony_ci/**
10ffe3c632Sopenharmony_ci * Whether a field is optional, required, or repeated.
11ffe3c632Sopenharmony_ci *
12ffe3c632Sopenharmony_ci * Protobuf type <code>google.protobuf.Field.Cardinality</code>
13ffe3c632Sopenharmony_ci */
14ffe3c632Sopenharmony_ciclass Cardinality
15ffe3c632Sopenharmony_ci{
16ffe3c632Sopenharmony_ci    /**
17ffe3c632Sopenharmony_ci     * For fields with unknown cardinality.
18ffe3c632Sopenharmony_ci     *
19ffe3c632Sopenharmony_ci     * Generated from protobuf enum <code>CARDINALITY_UNKNOWN = 0;</code>
20ffe3c632Sopenharmony_ci     */
21ffe3c632Sopenharmony_ci    const CARDINALITY_UNKNOWN = 0;
22ffe3c632Sopenharmony_ci    /**
23ffe3c632Sopenharmony_ci     * For optional fields.
24ffe3c632Sopenharmony_ci     *
25ffe3c632Sopenharmony_ci     * Generated from protobuf enum <code>CARDINALITY_OPTIONAL = 1;</code>
26ffe3c632Sopenharmony_ci     */
27ffe3c632Sopenharmony_ci    const CARDINALITY_OPTIONAL = 1;
28ffe3c632Sopenharmony_ci    /**
29ffe3c632Sopenharmony_ci     * For required fields. Proto2 syntax only.
30ffe3c632Sopenharmony_ci     *
31ffe3c632Sopenharmony_ci     * Generated from protobuf enum <code>CARDINALITY_REQUIRED = 2;</code>
32ffe3c632Sopenharmony_ci     */
33ffe3c632Sopenharmony_ci    const CARDINALITY_REQUIRED = 2;
34ffe3c632Sopenharmony_ci    /**
35ffe3c632Sopenharmony_ci     * For repeated fields.
36ffe3c632Sopenharmony_ci     *
37ffe3c632Sopenharmony_ci     * Generated from protobuf enum <code>CARDINALITY_REPEATED = 3;</code>
38ffe3c632Sopenharmony_ci     */
39ffe3c632Sopenharmony_ci    const CARDINALITY_REPEATED = 3;
40ffe3c632Sopenharmony_ci
41ffe3c632Sopenharmony_ci    private static $valueToName = [
42ffe3c632Sopenharmony_ci        self::CARDINALITY_UNKNOWN => 'CARDINALITY_UNKNOWN',
43ffe3c632Sopenharmony_ci        self::CARDINALITY_OPTIONAL => 'CARDINALITY_OPTIONAL',
44ffe3c632Sopenharmony_ci        self::CARDINALITY_REQUIRED => 'CARDINALITY_REQUIRED',
45ffe3c632Sopenharmony_ci        self::CARDINALITY_REPEATED => 'CARDINALITY_REPEATED',
46ffe3c632Sopenharmony_ci    ];
47ffe3c632Sopenharmony_ci
48ffe3c632Sopenharmony_ci    public static function name($value)
49ffe3c632Sopenharmony_ci    {
50ffe3c632Sopenharmony_ci        if (!isset(self::$valueToName[$value])) {
51ffe3c632Sopenharmony_ci            throw new UnexpectedValueException(sprintf(
52ffe3c632Sopenharmony_ci                    'Enum %s has no name defined for value %s', __CLASS__, $value));
53ffe3c632Sopenharmony_ci        }
54ffe3c632Sopenharmony_ci        return self::$valueToName[$value];
55ffe3c632Sopenharmony_ci    }
56ffe3c632Sopenharmony_ci
57ffe3c632Sopenharmony_ci    public static function value($name)
58ffe3c632Sopenharmony_ci    {
59ffe3c632Sopenharmony_ci        $const = __CLASS__ . '::' . strtoupper($name);
60ffe3c632Sopenharmony_ci        if (!defined($const)) {
61ffe3c632Sopenharmony_ci            throw new UnexpectedValueException(sprintf(
62ffe3c632Sopenharmony_ci                    'Enum %s has no value defined for name %s', __CLASS__, $name));
63ffe3c632Sopenharmony_ci        }
64ffe3c632Sopenharmony_ci        return constant($const);
65ffe3c632Sopenharmony_ci    }
66ffe3c632Sopenharmony_ci}
67ffe3c632Sopenharmony_ci
68ffe3c632Sopenharmony_ci// Adding a class alias for backwards compatibility with the previous class name.
69ffe3c632Sopenharmony_ciclass_alias(Cardinality::class, \Google\Protobuf\Field_Cardinality::class);
70ffe3c632Sopenharmony_ci
71