Author: Nick Sagona, III (nick@popphp.org)
Example #1
0
 public function testRender()
 {
     $i = InterfaceGenerator::factory('TestInterface');
     $i->setNamespace(new NamespaceGenerator('Test\\Space'))->setParent('TestParent')->setDocblock(new DocblockGenerator('This is a test desc.'))->addMethod(new MethodGenerator('testMethod'));
     $code = (string) $i;
     $code = $i->render(true);
     ob_start();
     $i->render();
     $output = ob_get_clean();
     $this->assertContains('interface TestInterface', $output);
     $this->assertContains('interface TestInterface', $code);
 }
Example #2
0
 /**
  * Render method
  *
  * @param  boolean $ret
  * @return mixed
  */
 public function render($ret = false)
 {
     $this->output = '<?php' . PHP_EOL;
     $this->output .= null !== $this->docblock ? $this->docblock->render(true) . PHP_EOL : null;
     if (null !== $this->namespace) {
         $this->output .= $this->namespace->render(true) . PHP_EOL;
     }
     if (null !== $this->code) {
         $this->output .= $this->code->render(true) . PHP_EOL;
     }
     if (null !== $this->body) {
         $this->output .= PHP_EOL . $this->body . PHP_EOL . PHP_EOL;
     }
     if ($this->close) {
         $this->output .= '?>' . PHP_EOL;
     }
     if ($ret) {
         return $this->output;
     } else {
         echo $this->output;
     }
 }