PDepend\Report\Jdepend\Chart::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 DependencyAnalyzer) {
            $this->analyzer = $analyzer;
            return true;
        }
        return false;
    }

Usage Example

 /**
  * Tests that the logger generates an image file.
  *
  * @return void
  */
 public function testGeneratesImageFile()
 {
     if (extension_loaded('imagick') === false) {
         $this->markTestSkipped('No pecl/imagick extension.');
     }
     $fileName = self::createRunResourceURI('jdepend-test-out.png');
     if (file_exists($fileName)) {
         unlink($fileName);
     }
     $nodes = new ASTArtifactList($this->_createPackages(true, true));
     $analyzer = new DependencyAnalyzer();
     $analyzer->analyze($nodes);
     $logger = new Chart();
     $logger->setLogFile($fileName);
     $logger->setArtifacts($nodes);
     $logger->log($analyzer);
     $this->assertFileNotExists($fileName);
     $logger->close();
     $this->assertFileExists($fileName);
     $info = getimagesize($fileName);
     $this->assertEquals(390, $info[0]);
     $this->assertEquals(250, $info[1]);
     $this->assertEquals('image/png', $info['mime']);
     unlink($fileName);
 }