Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Tree\Visitor\Dot Class Reference
Inheritance diagram for Hoa\Tree\Visitor\Dot:

Public Member Functions

 visit (Visitor\Element $element, &$handle=null, $eldnah=null)
 
- Public Member Functions inherited from Hoa\Tree\Visitor\Generic
 __construct ($order=self::PRE_ORDER)
 
 getOrder ()
 
- Public Member Functions inherited from Hoa\Visitor\Visit
 visit (Element $element, &$handle=null, $eldnah=null)
 

Protected Attributes

 $_i = 0
 
- Protected Attributes inherited from Hoa\Tree\Visitor\Generic
 $_order = self::PRE_ORDER
 

Additional Inherited Members

- Public Attributes inherited from Hoa\Tree\Visitor\Generic
const PRE_ORDER = 0
 
const IN_ORDER = 1
 
const POST_ORDER = 2
 
- Protected Member Functions inherited from Hoa\Tree\Visitor\Generic
 setOrder ($order)
 

Detailed Description

Class .

Transform a tree in DOT language.

Definition at line 49 of file Dot.php.

Member Function Documentation

Hoa\Tree\Visitor\Dot::visit ( Visitor\Element  $element,
$handle = null,
  $eldnah = null 
)

Visit an element.

Parameters
\Hoa\Visitor\Element$elementElement to visit.
mixed&$handleHandle (reference).
mixed$eldnahHandle (not reference).
Returns
string

Definition at line 68 of file Dot.php.

72  {
73  $ou = null;
74  $t = null;
75 
76  if ($this->_i == 0) {
77  $ou = 'digraph {' . "\n";
78  $t = '}' . "\n";
79  }
80 
81  $foo = $element->getValue();
82  $bar = null;
83  ++$this->_i;
84 
85  if (null == $eldnah) {
86  $eldnah = $foo;
87  $ou .= ' "' . md5($foo) . '" [label = "' . $foo . '"];' . "\n";
88  }
89 
90  foreach ($element->getChilds() as $child) {
91  $left = md5($eldnah);
92  $right = md5($eldnah . '.' . $child->getValue());
93 
94  $ou .=
95  ' "' . $left . '" -> "' . $right . '";' . "\n" .
96  ' "' . $right . '" [label = "' .
97  str_replace('\\', '\\\\', $child->getValue()) .
98  '"];' . "\n";
99  $bar .=
100  $child->accept($this, $handle, $eldnah . '.' .
101  $child->getValue());
102  }
103 
104  $ou .= $bar;
105 
106  --$this->_i;
107 
108  return $ou . $t;
109  }

Member Data Documentation

Hoa\Tree\Visitor\Dot::$_i = 0
protected

Definition at line 56 of file Dot.php.


The documentation for this class was generated from the following file: