/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('PHPMetrics by Jean-François Lépine <https://twitter.com/Halleck45>'); $output->writeln(''); $level = $input->getOption('level'); // config $configFactory = new ConfigFactory(); $config = $configFactory->factory($input); // files if (null === $config->getPath()->getBasePath()) { throw new \LogicException('Please provide a path to analyze'); } $finder = new Finder($config->getPath()->getExtensions(), $config->getPath()->getExcludedDirs()); // rules $rules = $config->getRuleSet(); $validator = new \Hal\Application\Rule\Validator($rules); // bounds $bounds = new Bounds(); // jobs queue planning $queue = new Queue(); $queue->push(new DoAnalyze($output, $finder, $config->getPath()->getBasePath(), !$input->getOption('without-oop')))->push(new SearchBounds($output, $bounds))->push(new DoAggregatedAnalyze($output, new DirectoryAggregatorFlat($level)))->push(new ReportRenderer($output, new Summary\Cli($validator, $bounds)))->push(new ReportWriter($config->getLogging()->getReport('html'), $output, new Summary\Html($validator, $bounds)))->push(new ReportWriter($config->getLogging()->getReport('json'), $output, new Details\Json($validator, $bounds)))->push(new ReportWriter($config->getLogging()->getReport('xml'), $output, new Summary\Xml($validator, $bounds)))->push(new ReportWriter($config->getLogging()->getReport('csv'), $output, new Details\Csv($validator, $bounds)))->push(new ReportWriter($config->getLogging()->getViolation('xml'), $output, new Xml($validator, $bounds)))->push(new ReportWriter($config->getLogging()->getChart('bubbles'), $output, new Bubbles($validator, $bounds))); // execute $collection = new \Hal\Component\Result\ResultCollection(); $aggregatedResults = new \Hal\Component\Result\ResultCollection(); $queue->execute($collection, $aggregatedResults); $output->writeln('<info>done</info>'); // evaluation of success $evaluator = new Evaluator($collection, $aggregatedResults, $bounds); $result = $evaluator->evaluate($config->getFailureCondition()); return $result->getCode(); }
/** * Factory queue * * @param Finder $finder * @param BoundsInterface $bounds * @return Queue */ public function factory(Finder $finder, BoundsInterface $bounds) { $rules = $this->config->getRuleSet(); $validator = new \Hal\Application\Rule\Validator($rules); // jobs queue planning $queue = new Queue(); $queue->push(new ReportRenderer(true, $this->output, new Summary\Cli($validator, $bounds, $this->output, $this->extensionsService)))->push(new ReportRenderer($this->config->getLogging()->getReport('cli'), $this->output, new Details\Cli($validator, $bounds, $this->extensionsService)))->push(new ReportWriter($this->config->getLogging()->getReport('html'), $this->output, new Summary\Html($validator, $bounds, $this->config->getTemplate(), $this->extensionsService)))->push(new ReportWriter($this->config->getLogging()->getReport('json'), $this->output, new Details\Json(true, $this->extensionsService)))->push(new ReportWriter($this->config->getLogging()->getReport('xml'), $this->output, new Summary\Xml($validator, $bounds, $this->extensionsService)))->push(new ReportWriter($this->config->getLogging()->getReport('csv'), $this->output, new Details\Csv($this->extensionsService)))->push(new ReportWriter($this->config->getLogging()->getViolation('xml'), $this->output, new Violations\Xml($validator, $bounds, $this->extensionsService)))->push(new ReportWriter($this->config->getLogging()->getChart('bubbles'), $this->output, new Chart\Bubbles($validator, $bounds, $this->extensionsService))); return $queue; }
/** * Factory queue * * @param Finder $finder * @param BoundsInterface $bounds * @return Queue */ public function factory(Finder $finder, BoundsInterface $bounds) { $rules = $this->config->getRuleSet(); $validator = new \Hal\Application\Rule\Validator($rules); // jobs queue planning $queue = new Queue(); $queue->push(new DoAnalyze($this->output, $finder, $this->config->getPath()->getBasePath(), !$this->input->getOption('without-oop')))->push(new SearchBounds($this->output, $bounds))->push(new DoAggregatedAnalyze($this->output, new DirectoryAggregatorFlat($this->input->getOption('level'))))->push(new CalculateScore(new Scoring($bounds)))->push(new ReportRenderer(true, $this->output, new Summary\Cli($validator, $bounds)))->push(new ReportRenderer($this->config->getLogging()->getReport('cli'), $this->output, new Details\Cli($validator, $bounds)))->push(new ReportWriter($this->config->getLogging()->getReport('html'), $this->output, new Summary\Html($validator, $bounds)))->push(new ReportWriter($this->config->getLogging()->getReport('json'), $this->output, new Details\Json($validator, $bounds)))->push(new ReportWriter($this->config->getLogging()->getReport('xml'), $this->output, new Summary\Xml($validator, $bounds)))->push(new ReportWriter($this->config->getLogging()->getReport('csv'), $this->output, new Details\Csv($validator, $bounds)))->push(new ReportWriter($this->config->getLogging()->getViolation('xml'), $this->output, new Violations\Xml($validator, $bounds)))->push(new ReportWriter($this->config->getLogging()->getChart('bubbles'), $this->output, new Chart\Bubbles($validator, $bounds))); return $queue; }
/** * Factory queue * * @param Finder $finder * @param BoundsInterface $bounds * @return Queue */ public function factory(Finder $finder, BoundsInterface $bounds) { $rules = $this->config->getRuleSet(); $validator = new Validator($rules); // jobs queue planning $queue = new Queue(); $queue->push(new DoAnalyze($this->output, $finder, $this->config->getPath()->getBasePath(), !$this->input->getOption('without-oop'), $this->config->getIgnoreErrors()))->push(new SearchBounds($this->output, $bounds))->push(new DoAggregatedAnalyze($this->output, new DirectoryAggregatorFlat($this->input->getOption('level'))))->push(new CalculateScore(new Scoring($bounds))); return $queue; }