/**
  * @param string $fromNode
  * @param string $toNode
  * @param array $attributes
  *
  * @return $this
  */
 public function addEdge($fromNode, $toNode, $attributes = [])
 {
     $edge = new Edge($this->graph->findNode($fromNode), $this->graph->findNode($toNode));
     $this->addAttributesTo($attributes, $edge);
     $this->graph->link($edge);
     return $this;
 }
Example #2
0
 protected function printFuncInto(Func $func, Graph $graph, $prefix)
 {
     $rendered = $this->render($func);
     $nodes = new \SplObjectStorage();
     foreach ($rendered['blocks'] as $block) {
         $blockId = $rendered['blockIds'][$block];
         $ops = $rendered['blocks'][$block];
         $output = '';
         foreach ($ops as $op) {
             $output .= $this->indent("\n" . $op['label']);
         }
         $nodes[$block] = $this->createNode($prefix . "block_" . $blockId, $output);
         $graph->setNode($nodes[$block]);
     }
     foreach ($rendered['blocks'] as $block) {
         foreach ($rendered['blocks'][$block] as $op) {
             foreach ($op['childBlocks'] as $child) {
                 $edge = $this->createEdge($nodes[$block], $nodes[$child['block']]);
                 $edge->setlabel($child['name']);
                 $graph->link($edge);
             }
         }
     }
     return $nodes[$func->cfg];
 }
Example #3
0
 /**
  * Transform the parent
  *
  * @param \Puml\Model\Object $child  The direct child of the parent
  *
  * @return void
  * @since 0.1
  * @throws Exception
  */
 protected function transformParent(\Puml\Model\Object $child)
 {
     if (!$child->hasParent()) {
         throw new \Exception('Unable to transform parent, when no parent available, on class ' . $child->getName());
     }
     $this->level++;
     $parent = $child->getParent();
     $this->transformObject($parent);
     $edge = new Edge($this->graph->findNode($child->getName()), $this->graph->findNode($parent->getName()));
     $edge->setArrowhead('empty');
     $this->graph->link($edge);
     if ($parent->hasParent()) {
         $this->transformParent($parent);
     }
 }
Example #4
0
 /**
  * @covers phpDocumentor\GraphViz\Graph::link
  * @todo   Implement testLink().
  */
 public function testLink()
 {
     $mock = $this->getMock('phpDocumentor\\GraphViz\\Edge', array(), array(), '', false);
     $this->assertSame($this->fixture, $this->fixture->link($mock));
 }