1<?php 2 3// Protocol Buffers - Google's data interchange format 4// Copyright 2017 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; 11 12class DescriptorPool 13{ 14 private static $pool; 15 16 private $internal_pool; 17 18 /** 19 * @return DescriptorPool 20 */ 21 public static function getGeneratedPool() 22 { 23 if (!isset(self::$pool)) { 24 self::$pool = new DescriptorPool(\Google\Protobuf\Internal\DescriptorPool::getGeneratedPool()); 25 } 26 return self::$pool; 27 } 28 29 private function __construct($internal_pool) 30 { 31 $this->internal_pool = $internal_pool; 32 } 33 34 /** 35 * @param string $className A fully qualified protobuf class name 36 * @return Descriptor 37 */ 38 public function getDescriptorByClassName($className) 39 { 40 $desc = $this->internal_pool->getDescriptorByClassName($className); 41 return is_null($desc) ? null : $desc->getPublicDescriptor(); 42 } 43 44 /** 45 * @param string $className A fully qualified protobuf class name 46 * @return EnumDescriptor 47 */ 48 public function getEnumDescriptorByClassName($className) 49 { 50 $desc = $this->internal_pool->getEnumDescriptorByClassName($className); 51 return is_null($desc) ? null : $desc->getPublicDescriptor(); 52 } 53} 54