/**
  * @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
 /**
  * @covers phpDocumentor\GraphViz\Graph::findNode
  */
 public function testFindNode()
 {
     $this->assertNull($this->fixture->findNode('MyNode'));
     $mock = $this->getMock('phpDocumentor\\GraphViz\\Node', array(), array(), '', false);
     $mock->expects($this->any())->method('getName')->will($this->returnValue('MyName'));
     $this->fixture->setNode($mock);
     $this->assertSame($mock, $this->fixture->findNode('MyName'));
     $subGraph = Graph::create();
     $mock2 = $this->getMock('phpDocumentor\\GraphViz\\Node', array(), array(), '', false);
     $mock2->expects($this->any())->method('getName')->will($this->returnValue('MyName2'));
     $subGraph->setNode($mock2);
     $this->fixture->addGraph($subGraph);
     $this->assertSame($mock2, $this->fixture->findNode('MyName2'));
 }
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);
     }
 }