Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
4 / 4 |
Factory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
4 / 4 |
create(Graph $g, $format) | |
100.00% |
1 / 1 |
2 | |
100.00% |
4 / 4 |
<?php | |
/* | |
* Mondrian | |
*/ | |
namespace Trismegiste\Mondrian\Transform\Format; | |
use Trismegiste\Mondrian\Graph\Graph; | |
/** | |
* Factory is a simple factory for export format for Graph | |
*/ | |
class Factory | |
{ | |
protected $typeList = array( | |
'dot' => 'Graphviz', | |
'json' => 'Json', | |
'svg' => 'Svg', | |
'html' => 'Html' | |
); | |
public function create(Graph $g, $format) | |
{ | |
if (array_key_exists($format, $this->typeList)) { | |
$classname = __NAMESPACE__ . '\\' . $this->typeList[$format]; | |
return new $classname($g); | |
} | |
throw new \InvalidArgumentException("Format $format is inknown"); | |
} | |
} |