예제 #1
0
 /**
  * Generates code
  */
 function it_generates_code(File $file, PrettyPrinterAbstract $printer)
 {
     $factory = new BuilderFactory();
     $file->getNamespaces()->willReturn([new PHPNamespace('test')]);
     $printer->prettyPrintFile([$factory->namespace('test')->getNode()])->willReturn('foo')->shouldBeCalled();
     $this->generate($file)->shouldReturn('foo');
 }
예제 #2
0
 /**
  * @param File $file
  *
  * @return mixed
  */
 public function generate(File $file)
 {
     $nodes = [];
     $namespaces = $file->getNamespaces();
     foreach ($namespaces as $namespace) {
         $nodes[] = $this->generateNamespace($namespace);
     }
     return $this->printer->prettyPrintFile($nodes);
 }