Example #1
0
 /**
  * This method will process all files that can be found in the given input
  * path. It will apply rules defined in the comma-separated <b>$ruleSets</b>
  * argument. The result will be passed to all given renderer instances.
  *
  * @param string                          $inputPath      File or directory
  * @param string                          $ruleSets       Rule-sets to apply
  * @param array(PHP_PMD_AbstractRenderer) $renderers      Report renderers
  * @param PHP_PMD_RuleSetFactory          $ruleSetFactory The factory to use
  *
  * @return void
  */
 public function processFiles($inputPath, $ruleSets, array $renderers, PHP_PMD_RuleSetFactory $ruleSetFactory)
 {
     $this->_input = $inputPath;
     $report = new PHP_PMD_Report();
     $factory = new PHP_PMD_ParserFactory();
     $parser = $factory->create($this);
     foreach ($ruleSetFactory->createRuleSets($ruleSets) as $ruleSet) {
         $parser->addRuleSet($ruleSet);
     }
     $report->start();
     $parser->parse($report);
     $report->end();
     foreach ($renderers as $renderer) {
         $renderer->start();
     }
     foreach ($renderers as $renderer) {
         $renderer->renderReport($report);
     }
     foreach ($renderers as $renderer) {
         $renderer->end();
     }
     $this->_violations = !$report->isEmpty();
 }
Example #2
0
 /**
  * Tests that the timer method returns the expected result.
  *
  * @return void
  * @covers PHP_PMD_Report
  * @group phpmd
  * @group unittest
  */
 public function testReportTimerReturnsMilliSeconds()
 {
     $start = microtime(true);
     $report = new PHP_PMD_Report();
     $report->start();
     usleep(50000);
     // 50 Milli Seconds
     $report->end();
     $time = ceil((microtime(true) - $start) * 1000.0);
     $this->assertGreaterThanOrEqual(50.0, $report->getElapsedTimeInMillis());
     $this->assertLessThanOrEqual($time, $report->getElapsedTimeInMillis());
 }