<?php

// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

namespace Google\Protobuf\Internal;

use Google\Protobuf\Internal\EnumDescriptor;

class EnumBuilderContext
{

    private $descriptor;
    private $pool;

    public function __construct($full_name, $klass, $pool)
    {
        $this->descriptor = new EnumDescriptor();
        $this->descriptor->setFullName($full_name);
        $this->descriptor->setClass($klass);
        $this->pool = $pool;
    }

    public function value($name, $number, $custom_json_name = null)
    {
        $value = new EnumValueDescriptor($name, $number, $custom_json_name);
        $this->descriptor->addValue($value);
        return $this;
    }

    public function finalizeToPool()
    {
        $this->pool->addEnumDescriptor($this->descriptor);
    }
}
