| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 36 | public function getImage($dotContent) { |
||
| 37 | |||
| 38 | if(!$this->isAvailable()) { |
||
| 39 | throw new \RuntimeException('Graphviz not installed'); |
||
| 40 | } |
||
| 41 | |||
| 42 | $dotFile = tempnam(sys_get_temp_dir(), 'phpmetrics-graphviz'); |
||
| 43 | $imageFile = tempnam(sys_get_temp_dir(), 'phpmetrics-graphviz'); |
||
| 44 | |||
| 45 | // dot file |
||
| 46 | $dotContent = str_replace('\\', '/', $dotContent); |
||
| 47 | file_put_contents($dotFile, $dotContent); |
||
| 48 | |||
| 49 | // image |
||
| 50 | shell_exec(sprintf('circo -Lg -Tsvg -o%2$s %1$s 2>&1', $dotFile, $imageFile)); |
||
| 51 | $content = file_get_contents($imageFile); |
||
| 52 | unlink($imageFile); |
||
| 53 | unlink($dotFile); |
||
| 54 | return $content; |
||
| 55 | } |
||
| 56 | } |