PDepend\Report\Overview\Pyramid::log PHP Method

log() public method

Adds an analyzer to log. If this logger accepts the given analyzer it with return true, otherwise the return value is false.
public log ( PDepend\Metrics\Analyzer $analyzer ) : boolean
$analyzer PDepend\Metrics\Analyzer The analyzer to log.
return boolean
    public function log(Analyzer $analyzer)
    {
        if ($analyzer instanceof CyclomaticComplexityAnalyzer) {
            $this->cyclomaticComplexity = $analyzer;
        } elseif ($analyzer instanceof CouplingAnalyzer) {
            $this->coupling = $analyzer;
        } elseif ($analyzer instanceof InheritanceAnalyzer) {
            $this->inheritance = $analyzer;
        } elseif ($analyzer instanceof NodeCountAnalyzer) {
            $this->nodeCount = $analyzer;
        } elseif ($analyzer instanceof NodeLocAnalyzer) {
            $this->nodeLoc = $analyzer;
        } else {
            return false;
        }
        return true;
    }

Usage Example

 /**
  * testCollectedAndComputedValuesInOutputSVG
  *
  * @return void
  */
 public function testCollectedAndComputedValuesInOutputSVG()
 {
     $output = self::createRunResourceURI('temp.svg');
     if (file_exists($output)) {
         unlink($output);
     }
     $log = new Pyramid();
     $log->setLogFile($output);
     $log->log($this->createCouplingAnalyzer());
     $log->log($this->createComplexityAnalyzer());
     $log->log($this->createInheritanceAnalyzer());
     $log->log($this->createNodeCountAnalyzer());
     $log->log($this->createNodeLocAnalyzer());
     $log->close();
     $this->assertFileExists($output);
     $expected = array('cyclo' => 5579, 'loc' => 35175, 'nom' => 3618, 'noc' => 384, 'nop' => 19, 'andc' => 0.31, 'ahh' => 0.12, 'calls' => 15128, 'fanout' => 8590, 'cyclo-loc' => 0.15, 'loc-nom' => 9.720000000000001, 'nom-noc' => 9.42, 'noc-nop' => 20.21, 'fanout-calls' => 0.5600000000000001, 'calls-nom' => 4.18);
     $svg = new \DOMDocument();
     $svg->load($output);
     // TODO: Replace this loop assertion
     foreach ($expected as $name => $value) {
         $elem = $svg->getElementById("pdepend.{$name}");
         $this->assertInstanceOf('\\DOMElement', $elem);
         $this->assertEquals($value, $elem->nodeValue, null, 0.01);
     }
     unlink($output);
 }