ANDC - Average Number of Derived Classes: The average number of direct
subclasses of a class. This metric only covers classes in the analyzed system,
no library or environment classes are covered.
AHH - Average Hierarchy Height: The computed average of all inheritance
trees within the analyzed system, external classes or interfaces are ignored.
/** * testAnalyzerNotCountsImplementedInterfaceMethodsAsOverwritten * * @return void */ public function testAnalyzerNotCountsImplementedInterfaceMethodsAsOverwritten() { $namespaces = self::parseCodeResourceForTest(); $class = $namespaces->current()->getClasses()->current(); $analyzer = new InheritanceAnalyzer(); $analyzer->analyze($namespaces); $metrics = $analyzer->getNodeMetrics($class); $this->assertEquals(1, $metrics['noom']); }
/** * Aggregates the required metrics from the registered analyzers. * * @return array(string => mixed) * @throws \RuntimeException If one of the required analyzers isn't set. */ private function collectMetrics() { if ($this->coupling === null) { throw new \RuntimeException('Missing Coupling analyzer.'); } if ($this->cyclomaticComplexity === null) { throw new \RuntimeException('Missing Cyclomatic Complexity analyzer.'); } if ($this->inheritance === null) { throw new \RuntimeException('Missing Inheritance analyzer.'); } if ($this->nodeCount === null) { throw new \RuntimeException('Missing Node Count analyzer.'); } if ($this->nodeLoc === null) { throw new \RuntimeException('Missing Node LOC analyzer.'); } $coupling = $this->coupling->getProjectMetrics(); $cyclomatic = $this->cyclomaticComplexity->getProjectMetrics(); $inheritance = $this->inheritance->getProjectMetrics(); $nodeCount = $this->nodeCount->getProjectMetrics(); $nodeLoc = $this->nodeLoc->getProjectMetrics(); return array('cyclo' => $cyclomatic['ccn2'], 'loc' => $nodeLoc['eloc'], 'nom' => $nodeCount['nom'] + $nodeCount['nof'], 'noc' => $nodeCount['noc'], 'nop' => $nodeCount['nop'], 'ahh' => round($inheritance['ahh'], 3), 'andc' => round($inheritance['andc'], 3), 'fanout' => $coupling['fanout'], 'calls' => $coupling['calls']); }
/** * testInheritanceAnalyzerNotRunsEndlessForDeepInterfaceHierarchy * * @return void */ public function testInheritanceAnalyzerNotRunsEndlessForDeepInterfaceHierarchy() { set_time_limit(5); $analyzer = new InheritanceAnalyzer(); $analyzer->analyze($this->parseCodeResourceForTest()); }