• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
12class FileDescriptor
13{
14
15    private $package;
16    private $message_type = [];
17    private $enum_type = [];
18
19    public function setPackage($package)
20    {
21        $this->package = $package;
22    }
23
24    public function getPackage()
25    {
26        return $this->package;
27    }
28
29    public function getMessageType()
30    {
31        return $this->message_type;
32    }
33
34    public function addMessageType($desc)
35    {
36        $this->message_type[] = $desc;
37    }
38
39    public function getEnumType()
40    {
41        return $this->enum_type;
42    }
43
44    public function addEnumType($desc)
45    {
46        $this->enum_type[]= $desc;
47    }
48
49    public static function buildFromProto($proto)
50    {
51        $file = new FileDescriptor();
52        $file->setPackage($proto->getPackage());
53        foreach ($proto->getMessageType() as $message_proto) {
54            $file->addMessageType(Descriptor::buildFromProto(
55                $message_proto, $proto, ""));
56        }
57        foreach ($proto->getEnumType() as $enum_proto) {
58            $file->addEnumType(
59                EnumDescriptor::buildFromProto(
60                    $enum_proto,
61                    $proto,
62                    ""));
63        }
64        return $file;
65    }
66}
67