/**
  * @param string $name
  * @param array $attributes
  * @param string $group
  *
  * @return $this
  */
 public function addNode($name, $attributes = [], $group = self::DEFAULT_GROUP)
 {
     $node = new Node($name);
     $this->addAttributesTo($attributes, $node);
     if ($group !== self::DEFAULT_GROUP) {
         $graph = $this->getGraphByName($group);
         $graph->setNode($node);
     } else {
         $this->graph->setNode($node);
     }
     return $this;
 }
Example #2
0
 /**
  * Transform the object to an UML scheme
  *
  * @param \Puml\Model\Object $object
  *
  * @return void
  * @since 0.1
  */
 protected function transformObject(\Puml\Model\Object $object)
 {
     $label = implode('|', array(addslashes($object->getName()), implode($this->transformProperties($object->getProperties())), implode($this->transformMethods($object->getMethods()))));
     $node = new Node($object->getName());
     $node->setShape('record')->setPos('0, ' . (0 + $this->level * 3) . '!')->setLabel('"{' . $label . '}"');
     $this->graph->setNode($node);
 }
Example #3
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 #4
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'));
 }