/** * 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'); }
/** * @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); }