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

getNodeMetrics() public method

Returns the calculated metrics for the given node or an empty array when no metrics exist for the given node.
public getNodeMetrics ( PDepend\Source\AST\ASTArtifact $artifact ) : array(string=>float)
$artifact PDepend\Source\AST\ASTArtifact
return array(string=>float)
    public function getNodeMetrics(ASTArtifact $artifact)
    {
        if (isset($this->metrics[$artifact->getId()])) {
            return $this->metrics[$artifact->getId()];
        }
        return array();
    }

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());
 }