1<?php 2 3// Protocol Buffers - Google's data interchange format 4// Copyright 2008 Google Inc. All rights reserved. 5// 6// Use of this source code is governed by a BSD-style 7// license that can be found in the LICENSE file or at 8// https://developers.google.com/open-source/licenses/bsd 9 10namespace Google\Protobuf\Internal; 11 12use Google\Protobuf\Internal\EnumDescriptor; 13use Google\Protobuf\EnumValueDescriptor; 14 15class EnumBuilderContext 16{ 17 18 private $descriptor; 19 private $pool; 20 21 public function __construct($full_name, $klass, $pool) 22 { 23 $this->descriptor = new EnumDescriptor(); 24 $this->descriptor->setFullName($full_name); 25 $this->descriptor->setClass($klass); 26 $this->pool = $pool; 27 } 28 29 public function value($name, $number) 30 { 31 $value = new EnumValueDescriptor($name, $number); 32 $this->descriptor->addValue($number, $value); 33 return $this; 34 } 35 36 public function finalizeToPool() 37 { 38 $this->pool->addEnumDescriptor($this->descriptor); 39 } 40} 41