Author: Thomas Gossmann
Inheritance: extends AbstractPhpStruct, implements gossi\codegen\model\GenerateableInterface, implements gossi\codegen\model\ConstantsInterface, use trait gossi\codegen\model\parts\ConstantsPart, use trait gossi\codegen\model\parts\InterfacesPart
 private function buildSignature(PhpInterface $model)
 {
     $this->writer->write('interface ');
     $this->writer->write($model->getName());
     if ($model->hasInterfaces()) {
         $this->writer->write(' extends ');
         $this->writer->write(implode(', ', $model->getInterfaces()->toArray()));
     }
 }
 /**
  * Removes an interface.
  * 
  * If the interface is passed as PhpInterface object, 
  * the interface is also remove from the use statements.
  *
  * @param PhpInterface|string $interface interface or qualified name
  * @return $this
  */
 public function removeInterface($interface)
 {
     if ($interface instanceof PhpInterface) {
         $name = $interface->getName();
         $qname = $interface->getQualifiedName();
         $this->removeUseStatement($qname);
     } else {
         $name = $interface;
     }
     $index = array_search($name, $this->interfaces);
     if ($index) {
         unset($this->interfaces[$name]);
     }
     return $this;
 }
 public function testSignature()
 {
     $expected = 'interface MyInterface {' . "\n" . '}';
     $trait = PhpInterface::create('MyInterface');
     $codegen = new CodeGenerator(['generateDocblock' => false, 'generateEmptyDocblock' => false]);
     $code = $codegen->generate($trait);
     $this->assertEquals($expected, $code);
 }
 public function testCreate()
 {
     $class = PhpClass::create();
     $this->assertTrue($class instanceof PhpClass);
     $interface = PhpInterface::create();
     $this->assertTrue($interface instanceof PhpInterface);
     $trait = PhpTrait::create();
     $this->assertTrue($trait instanceof PhpTrait);
 }
 public function testExtends()
 {
     $generator = new ModelGenerator();
     $expected = 'interface MyInterface extends \\Iterator {' . "\n" . '}';
     $interface = PhpInterface::create('MyInterface')->addInterface('\\Iterator');
     $this->assertEquals($expected, $generator->generate($interface));
     $expected = 'interface MyInterface extends \\Iterator, \\ArrayAccess {' . "\n" . '}';
     $interface = PhpInterface::create('MyInterface')->addInterface('\\Iterator')->addInterface('\\ArrayAccess');
     $this->assertEquals($expected, $generator->generate($interface));
 }
 public function testEmptyInterface()
 {
     $interface = new PhpInterface();
     $interface->generateDocblock();
     $this->assertTrue($interface->getDocblock()->isEmpty());
 }
 public function testMyCollectionInterface()
 {
     $interface = PhpInterface::fromFile(__DIR__ . '/../fixtures/MyCollectionInterface.php');
     $interface->hasInterface('phootwork\\collection\\Collection');
 }
 /**
  * Removes an interface.
  *
  * If the interface is passed as PhpInterface object,
  * the interface is also remove from the use statements.
  *
  * @param PhpInterface|string $interface interface or qualified name
  * @return $this
  */
 public function removeInterface($interface)
 {
     if ($interface instanceof PhpInterface) {
         $name = $interface->getName();
         $qname = $interface->getQualifiedName();
         $this->removeUseStatement($qname);
     } else {
         $name = $interface;
     }
     $this->interfaces->remove($name);
     return $this;
 }
 /**
  * Creates DummyInterface
  * 
  * @return PhpInterface
  */
 public static function createDummyInterface()
 {
     $interface = PhpInterface::create('DummyInterface')->setNamespace('gossi\\codegen\\tests\\fixtures')->setDescription('Dummy docblock')->setMethod(PhpMethod::create('foo'));
     $interface->generateDocblock();
     return $interface;
 }