private function buildSignature(PhpClass $model) { if ($model->isAbstract()) { $this->writer->write('abstract '); } if ($model->isFinal()) { $this->writer->write('final '); } $this->writer->write('class '); $this->writer->write($model->getName()); if ($parentClassName = $model->getParentClassName()) { $this->writer->write(' extends ' . $parentClassName); } if ($model->hasInterfaces()) { $this->writer->write(' implements '); $this->writer->write(implode(', ', $model->getInterfaces()->toArray())); } }
public function testInterfaces() { $class = new PhpClass('my\\name\\space\\Class'); $this->assertFalse($class->hasInterfaces()); $this->assertTrue($class->getInterfaces()->isEmpty()); $this->assertSame($class, $class->setInterfaces(['foo', 'bar'])); $this->assertEquals(['foo', 'bar'], $class->getInterfaces()->toArray()); $this->assertSame($class, $class->addInterface('stdClass')); $this->assertEquals(['foo', 'bar', 'stdClass'], $class->getInterfaces()->toArray()); $this->assertTrue($class->hasInterfaces()); $interface = new PhpInterface('my\\name\\space\\Interface'); $class->addInterface($interface); $this->assertTrue($class->hasInterface('my\\name\\space\\Interface')); $this->assertSame($class, $class->removeInterface($interface)); $class->addInterface(new PhpInterface('other\\name\\space\\Interface')); $this->assertTrue($class->hasUseStatement('other\\name\\space\\Interface')); $this->assertSame($class, $class->removeInterface('other\\name\\space\\Interface')); $this->assertTrue($class->hasUseStatement('other\\name\\space\\Interface')); }