aboutsummaryrefslogtreecommitdiff
path: root/php/src/Google/Protobuf/Internal/EnumDescriptor.php
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2017-07-18 16:26:16 -0700
committerJisi Liu <jisi.liu@gmail.com>2017-07-18 16:26:16 -0700
commit3af881c7e2db0553207876acbdb91c6e77974e44 (patch)
tree35e2a96cce802d4235bd29afa396e28ead892fa2 /php/src/Google/Protobuf/Internal/EnumDescriptor.php
parent86975301f1876ce1934612777b8ca6c76520f5cc (diff)
parent942a29cecd36f2a4b22fdd2179635cd548e6bd27 (diff)
downloadprotobuf-3af881c7e2db0553207876acbdb91c6e77974e44.tar.gz
protobuf-3af881c7e2db0553207876acbdb91c6e77974e44.tar.bz2
protobuf-3af881c7e2db0553207876acbdb91c6e77974e44.zip
Merge master into 3.4.x
Diffstat (limited to 'php/src/Google/Protobuf/Internal/EnumDescriptor.php')
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptor.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
new file mode 100644
index 00000000..33a55a4a
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace Google\Protobuf\Internal;
+
+class EnumDescriptor
+{
+
+ private $klass;
+ private $full_name;
+ private $value;
+ private $name_to_value;
+
+ public function setFullName($full_name)
+ {
+ $this->full_name = $full_name;
+ }
+
+ public function getFullName()
+ {
+ return $this->full_name;
+ }
+
+ public function addValue($number, $value)
+ {
+ $this->value[$number] = $value;
+ $this->name_to_value[$value->getName()] = $value;
+ }
+
+ public function getValueByNumber($number)
+ {
+ return $this->value[$number];
+ }
+
+ public function getValueByName($name)
+ {
+ return $this->name_to_value[$name];
+ }
+
+ public function setClass($klass)
+ {
+ $this->klass = $klass;
+ }
+
+ public function getClass()
+ {
+ return $this->klass;
+ }
+
+ public static function buildFromProto($proto, $file_proto, $containing)
+ {
+ $desc = new EnumDescriptor();
+
+ $enum_name_without_package = "";
+ $classname = "";
+ $fullname = "";
+ GPBUtil::getFullClassName(
+ $proto,
+ $containing,
+ $file_proto,
+ $enum_name_without_package,
+ $classname,
+ $fullname);
+ $desc->setFullName($fullname);
+ $desc->setClass($classname);
+ $values = $proto->getValue();
+ foreach ($values as $value) {
+ $desc->addValue($value->getNumber(), $value);
+ }
+
+ return $desc;
+ }
+}