/**
* Executes the current command.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null|integer null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$finder = new FinderFacade($input->getArgument('values'), $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'));
$files = $finder->findFiles();
if (empty($files)) {
$output->writeln('No files found to scan');
exit(1);
}
$progressHelper = null;
if ($input->getOption('progress')) {
$progressHelper = $this->getHelperSet()->get('progress');
$progressHelper->start($output, count($files));
}
$strategy = new DefaultStrategy();
$detector = new Detector($strategy, $progressHelper);
$quiet = $output->getVerbosity() == OutputInterface::VERBOSITY_QUIET;
$clones = $detector->copyPasteDetection($files, $input->getOption('min-lines'), $input->getOption('min-tokens'), $input->getOption('fuzzy'));
if ($input->getOption('progress')) {
$progressHelper->finish();
$output->writeln('');
}
if (!$quiet) {
$printer = new Text();
$printer->printResult($output, $clones);
unset($printer);
}
$logPmd = $input->getOption('log-pmd');
if ($logPmd) {
$pmd = new PMD($logPmd);
$pmd->processClones($clones);
unset($pmd);
}
if (!$quiet) {
print \PHP_Timer::resourceUsage() . "\n";
}
if (count($clones) > 0) {
exit(1);
}
}