/**
  * {@inheritdoc}
  */
 public function visit(Entity $entity)
 {
     $name = $entity->getName();
     $namespace = $entity->getNamespace();
     $shortDescription = 'Protobuf service : ' . $entity->getClass();
     $class = InterfaceGenerator::fromArray(['name' => $name, 'namespacename' => $namespace, 'methods' => $this->generateMethods($entity), 'docblock' => ['shortDescription' => $shortDescription]]);
     $entity->setContent($this->generateFileContent($class, $entity));
 }
 /**
  * {@inheritdoc}
  */
 public function visit(Entity $entity)
 {
     $name = $entity->getName();
     $namespace = $entity->getNamespace();
     $shortDescription = 'Protobuf extension : ' . $entity->getClass();
     $class = ClassGenerator::fromArray(['name' => $name, 'namespacename' => $namespace, 'implementedinterfaces' => ['\\Protobuf\\Extension'], 'properties' => $this->generateFields($entity), 'methods' => $this->generateMethods($entity), 'docblock' => ['shortDescription' => $shortDescription]]);
     $entity->setContent($this->generateFileContent($class, $entity));
 }
 /**
  * {@inheritdoc}
  */
 public function visit(Entity $entity)
 {
     $name = $entity->getName();
     $namespace = $entity->getNamespace();
     $descriptor = $entity->getDescriptor();
     $shortDescription = 'Protobuf message : ' . $entity->getClass();
     $class = ClassGenerator::fromArray(['name' => $name, 'namespacename' => $namespace, 'extendedClass' => '\\Protobuf\\AbstractMessage', 'docblock' => ['shortDescription' => $shortDescription]]);
     foreach ($this->generators as $generator) {
         $generator->visit($entity, $class);
     }
     $entity->setContent($this->generateFileContent($class, $entity));
 }
 public function testGetNamespaceUsingPhpOptions()
 {
     $name = 'SimpleMessage';
     $type = Entity::TYPE_MESSAGE;
     $descriptor = new DescriptorProto();
     $fileDescriptor1 = new FileDescriptorProto();
     $fileDescriptor2 = new FileDescriptorProto();
     $fileDescriptor3 = new FileDescriptorProto();
     $fileOptions2 = new FileOptions();
     $fileOptions3 = new FileOptions();
     $fileOptions2->extensions()->put(Extension::package(), 'Package');
     $fileOptions3->extensions()->put(Extension::package(), 'Package');
     $fileDescriptor1->setPackage('package');
     $fileDescriptor2->setPackage('package');
     $fileDescriptor3->setPackage('package');
     $fileDescriptor2->setOptions($fileOptions2);
     $fileDescriptor3->setOptions($fileOptions3);
     $entity1 = new Entity($type, $name, $descriptor, $fileDescriptor1);
     $entity2 = new Entity($type, $name, $descriptor, $fileDescriptor2);
     $entity3 = new Entity($type, $name, $descriptor, $fileDescriptor3, 'Parent');
     $this->assertEquals('package', $entity1->getNamespace());
     $this->assertEquals('Package', $entity2->getNamespace());
     $this->assertEquals('Package\\Parent', $entity3->getNamespace());
 }