Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
20 / 20 |
PrettyPrint | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
20 / 20 |
extractShortName(Vertex $v) | |
100.00% |
1 / 1 |
2 | |
100.00% |
5 / 5 |
|||
__toString() | |
100.00% |
1 / 1 |
3 | |
100.00% |
15 / 15 |
<?php | |
/* | |
* Mondrian | |
*/ | |
namespace Trismegiste\Mondrian\Graph; | |
/** | |
* PrettyPrint is Decorator for pretty printing a graph | |
* | |
* @author flo | |
*/ | |
class PrettyPrint extends Algorithm | |
{ | |
private function extractShortName(Vertex $v) | |
{ | |
$result = 'Unknown'; | |
if (preg_match('#([^\\\\]+)$#', get_class($v), $match)) { | |
$result = $match[1]; | |
} | |
return $result; | |
} | |
public function __toString() | |
{ | |
ob_start(); | |
foreach ($this->getVertexSet() as $vertex) { | |
$cls = $this->extractShortName($vertex); | |
echo "$cls : "; | |
echo $vertex->getName() . PHP_EOL; | |
$edgeList = $this->getSuccessor($vertex); | |
foreach ($edgeList as $item) { | |
$cls = $this->extractShortName($item); | |
echo " -> $cls : "; | |
echo $item->getName() . PHP_EOL; | |
} | |
} | |
$content = ob_get_contents(); | |
ob_end_clean(); | |
return $content; | |
} | |
} |