/**
  * Creates a Descriptor from the provided data.
  *
  * @param InterfaceReflector $data
  *
  * @return InterfaceDescriptor
  */
 public function create($data)
 {
     $interfaceDescriptor = new InterfaceDescriptor();
     $interfaceDescriptor->setFullyQualifiedStructuralElementName($data->getName());
     $interfaceDescriptor->setName($data->getShortName());
     $interfaceDescriptor->setLine($data->getLinenumber());
     $interfaceDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');
     // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
     $interfaceDescriptor->setNamespace('\\' . (strtolower($data->getNamespace()) == 'global' ? '' : $data->getNamespace()));
     $this->assembleDocBlock($data->getDocBlock(), $interfaceDescriptor);
     $this->addConstants($data->getConstants(), $interfaceDescriptor);
     $this->addMethods($data->getMethods(), $interfaceDescriptor);
     foreach ($data->getParentInterfaces() as $interfaceClassName) {
         $interfaceDescriptor->getParent()->set($interfaceClassName, $interfaceClassName);
     }
     return $interfaceDescriptor;
 }
 /**
  * @covers phpDocumentor\Compiler\Pass\PackageTreeBuilder::execute
  * @covers phpDocumentor\Compiler\Pass\PackageTreeBuilder::addElementsOfTypeToPackage
  */
 public function testAddInterfaceToNamespace()
 {
     $interface = new InterfaceDescriptor();
     $interface->setPackage('My\\Space');
     $interface->setFullyQualifiedStructuralElementName('My\\Space\\Interface1');
     $this->project->getFiles()->get(0)->getInterfaces()->add($interface);
     // double check if a second interface in the same deep namespace ends up at the right location
     $interface2 = new InterfaceDescriptor();
     $interface2->setPackage('My\\Space');
     $interface2->setFullyQualifiedStructuralElementName('My\\Space\\Interface2');
     $this->project->getFiles()->get(0)->getInterfaces()->add($interface2);
     $this->fixture->execute($this->project);
     $this->assertSame(array($interface, $interface2), $this->project->getIndexes()->get('packages')->get('\\My\\Space')->getInterfaces()->getAll());
 }