/** * @param Analyser $analyser * @param RepositoryInterface $repository * @param FormatterInterface $formatter * @param ImporterInterface $importer */ public function __construct(Analyser $analyser, RepositoryInterface $repository, FormatterInterface $formatter, ImporterInterface $importer) { parent::__construct('SimpSpector', 'dev'); $this->add(new AnalyseCommand($analyser, $formatter)); $this->add(new ReferenceCommand($repository)); $this->add(new DiffCommand($importer, new Calculator(), $analyser->getExecutor(), $analyser->getLoader())); }
/** * * @param InputInterface $input * @param OutputInterface $output * @return int|null|void * @throws \Exception */ protected function execute(InputInterface $input, OutputInterface $output) { /** @var string $format */ $format = $input->getOption('format'); if (!$this->formatter->formatExists($format)) { $output->writeln(sprintf('<error>Format "%s" does not exist</error>', $format)); return; } $result = $this->analyser->analyse($input->getArgument('path'), $input->getOption('config'), new ConsoleLogger($output)); $string = $this->formatter->format($result, $format); if ($file = $input->getOption('output')) { file_put_contents($file, $string); } else { $output->writeln(""); $output->writeln(""); $output->writeln($string); } }