protected function execute(InputInterface $input, OutputInterface $output)
{
$graph = new GraphComposer($input->getArgument('dir'));
$target = $input->getArgument('output');
if ($target !== null) {
if (is_dir($target)) {
$target = rtrim($target, '/') . '/graph-composer.svg';
}
$filename = basename($target);
$pos = strrpos($filename, '.');
if ($pos !== false && isset($filename[$pos + 1])) {
// extension found and not empty
$graph->setFormat(substr($filename, $pos + 1));
}
}
$format = $input->getOption('format');
if ($format !== null) {
$graph->setFormat($format);
}
$path = $graph->getImagePath();
if ($target !== null) {
rename($path, $target);
} else {
readfile($path);
}
}