PDepend\Metrics\Analyzer\CrapIndexAnalyzer::addAnalyzer PHP Method

addAnalyzer() public method

Adds an analyzer that this analyzer depends on.
public addAnalyzer ( PDepend\Metrics\Analyzer $analyzer ) : void
$analyzer PDepend\Metrics\Analyzer
return void
    public function addAnalyzer(Analyzer $analyzer)
    {
        $this->ccnAnalyzer = $analyzer;
    }

Usage Example

 /**
  * Calculates the crap index.
  *
  * @param string  $testCase Name of the calling test case.
  * @param integer $ccn      The entire cyclomatic complexity number.
  *
  * @return array
  */
 private function _calculateCrapIndex($testCase, $ccn)
 {
     $namespaces = self::parseCodeResourceForTest();
     $options = array('coverage-report' => $this->_createCloverReportFile());
     $analyzer = new CrapIndexAnalyzer($options);
     $analyzer->addAnalyzer($this->_createCyclomaticComplexityAnalyzerMock($ccn));
     $analyzer->analyze($namespaces);
     $namespaces->rewind();
     if ($namespaces->current()->getTypes()->count() > 0) {
         return $analyzer->getNodeMetrics($namespaces->current()->getTypes()->current()->getMethods()->current());
     }
     return $analyzer->getNodeMetrics($namespaces->current()->getFunctions()->current());
 }