Beispiel #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $graph = new GraphComposer($input->getArgument('dir'));
     $target = $input->getArgument('output');
     if ($target !== null) {
         if (is_dir($target)) {
             $target = rtrim($target, '/') . '/graph-composer.svg';
         }
         $filename = basename($target);
         $pos = strrpos($filename, '.');
         if ($pos !== false && isset($filename[$pos + 1])) {
             // extension found and not empty
             $graph->setFormat(substr($filename, $pos + 1));
         }
     }
     $format = $input->getOption('format');
     if ($format !== null) {
         $graph->setFormat($format);
     }
     $path = $graph->getImagePath();
     if ($target !== null) {
         rename($path, $target);
     } else {
         readfile($path);
     }
 }
 public function testWillSetFormat()
 {
     $dir = __DIR__ . '/../';
     $graphviz = $this->getMock('Graphp\\GraphViz\\GraphViz');
     $graphviz->expects($this->once())->method('setFormat')->with($this->equalTo('gif'));
     $graphComposer = new GraphComposer($dir, $graphviz);
     $ret = $graphComposer->setFormat('gif');
     $this->assertEquals($graphComposer, $ret);
 }
Beispiel #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $graph = new GraphComposer($input->getArgument('dir'));
     $graph->setFormat($input->getOption('format'));
     $graph->displayGraph();
 }