Пример #1
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $source = $input->getArgument('source');
     if (is_dir($source) === false && is_file($source) === false) {
         throw new \InvalidArgumentException(sprintf('"%s" is not a file or a directory', $source));
     }
     $logger = new Logger($this->output, $input->getOption('debug'));
     if (is_dir($source) === true) {
         $collector = new DirectoryCodeCollector(array($source));
     } elseif (is_file($source) === true) {
         $collector = new FileCodeCollector(array($source));
     }
     foreach ($this->engine->convert($collector, $logger, $input->getArgument('file')) as $file) {
         $this->fileRender->render($file);
     }
     $table = new Table($this->output);
     $table->setHeaders(array(array(new TableCell('Incompatibility', array('colspan' => 4))), array('Type', 'Message', 'Line', 'Class')));
     $table->setRows($logger->getIncompatibility());
     $table->render();
     if ($input->getOption('v') === true) {
         $table = new Table($this->output);
         $table->setHeaders(array(array(new TableCell('Log', array('colspan' => 3))), array('Message', 'Line', 'Class')));
         $table->setRows($logger->getLogs());
         $table->render();
     }
 }
Пример #2
0
 public function testInstance()
 {
     $fileWriter = $this->getMock('PhpToZephir\\FileWriter');
     $fileWriter->expects($this->once())->method('write')->with(array('zephir' => 'test'));
     $sUT = new FileRender($fileWriter);
     $sUT->render(array('zephir' => 'test'));
 }
Пример #3
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $directory = $input->getArgument('dir');
     if (is_dir($directory) === false) {
         throw new \InvalidArgumentException(sprintf('Directory "%s" does not exist', $directory));
     }
     $logger = new Logger($this->output, $input->getOption('debug'));
     $directoryCollector = new DirectoryCodeCollector(array($directory));
     foreach ($this->engine->convert($directoryCollector, $logger, $input->getArgument('file')) as $file) {
         $this->fileRender->render($file);
     }
 }
Пример #4
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);
     }
 }