/**
  * @return \PhpToZephir\Engine
  */
 private function getEngine()
 {
     if (self::$engine === null) {
         self::$engine = EngineFactory::getInstance();
     }
     return self::$engine;
 }
示例#2
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $engine = EngineFactory::getInstance(new Logger($output, $input->getOption('debug')));
     $dir = $input->getArgument('dir');
     $fileWriter = new FileWriter();
     if (is_dir($dir) === false) {
         throw new \Exception(sprintf('Directory "%s" does not exist', $dir));
     }
     $render = new FileRender(new FileWriter());
     foreach ($engine->convert(new DirectoryCodeCollector(array($dir)), $input->getArgument('file')) as $file) {
         $render->render($file);
     }
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $engine = EngineFactory::getInstance(new Logger($output, $input->getOption('debug')));
     $dir = $input->getArgument('dir');
     $fileWriter = new FileWriter();
     if (is_dir($dir) === false) {
         throw new \Exception(sprintf('Directory "%s" does not exist', $dir));
     }
     foreach ($engine->convertDirectory($dir, true, $input->getArgument('file')) as $file => $convertedCode) {
         $output->writeln(sprintf('<info>Converted %s</info>', $convertedCode['fileDestination']));
         $fileWriter->write($convertedCode);
     }
 }
 /**
  * @param OutputInterface $output
  *
  * @return \PhpToZephir\Command\Convert
  */
 public static function getInstance(OutputInterface $output)
 {
     return new Convert(EngineFactory::getInstance(), new FileRender(new FileWriter()), $output);
 }
示例#5
0
 public function testFailOnDirectory()
 {
     $sUT = new ConvertDirectory(EngineFactory::getInstance(), new FileRender(new FileWriter()), new NullOutput());
     $this->setExpectedException('\\InvalidArgumentException', 'Directory "not" does not exist');
     $sUT->execute(new ArrayInput(array('dir' => 'not'), $sUT->getDefinition()), new NullOutput());
 }
 public function testInstance()
 {
     $this->assertInstanceOf('\\PhpToZephir\\Engine', EngineFactory::getInstance(new Logger(new NullOutput(), false)));
 }