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 12use Google\Protobuf\Internal\GetPublicDescriptorTrait; 13 14class Descriptor 15{ 16 use GetPublicDescriptorTrait; 17 18 private $internal_desc; 19 20 /** 21 * @internal 22 */ 23 public function __construct($internal_desc) 24 { 25 $this->internal_desc = $internal_desc; 26 } 27 28 /** 29 * @return string Full protobuf message name 30 */ 31 public function getFullName() 32 { 33 return trim($this->internal_desc->getFullName(), "."); 34 } 35 36 /** 37 * @return string PHP class name 38 */ 39 public function getClass() 40 { 41 return $this->internal_desc->getClass(); 42 } 43 44 /** 45 * @param int $index Must be >= 0 and < getFieldCount() 46 * @return FieldDescriptor 47 */ 48 public function getField($index) 49 { 50 return $this->getPublicDescriptor($this->internal_desc->getFieldByIndex($index)); 51 } 52 53 /** 54 * @return int Number of fields in message 55 */ 56 public function getFieldCount() 57 { 58 return count($this->internal_desc->getField()); 59 } 60 61 /** 62 * @param int $index Must be >= 0 and < getOneofDeclCount() 63 * @return OneofDescriptor 64 */ 65 public function getOneofDecl($index) 66 { 67 return $this->getPublicDescriptor($this->internal_desc->getOneofDecl()[$index]); 68 } 69 70 /** 71 * @return int Number of oneofs in message 72 */ 73 public function getOneofDeclCount() 74 { 75 return count($this->internal_desc->getOneofDecl()); 76 } 77 78 /** 79 * @return int Number of real oneofs in message 80 */ 81 public function getRealOneofDeclCount() 82 { 83 return $this->internal_desc->getRealOneofDeclCount(); 84 } 85} 86