/** * @inheritdoc */ public function terminate(ResultCollection $collection, ResultCollection $groupedResults) { $text = 'digraph G {' . PHP_EOL . 'bgcolor=white;' . PHP_EOL . 'node [shape=circle, color=lightblue2, style=filled];'; $width = 300; foreach ($collection as $item) { // color $valid = $this->validator->validate('maintenabilityIndex', $item->getMaintenabilityIndex()->getMaintenabilityIndex()); switch ($valid) { case Validator::CRITICAL: $color = 'red'; break; case Validator::GOOD: $color = 'chartreuse4'; break; case Validator::WARNING: $color = 'gold1'; break; case Validator::UNKNOWN: $color = 'grey'; break; } // size $size = round($item->getMcCabe()->getCyclomaticComplexityNumber() * $width / 100); $text .= PHP_EOL . sprintf('"%1$s" [color=%2$s, tooltip="%3$s", width=%4$s, height=%4$s, label=""];', $item->getName(), $color, $item->getName(), $size, $size); } $text .= PHP_EOL . '}'; $chart = new Graphviz(); return $chart->getImage($text); }
/** * @param Configuration $config */ public function validates(Configuration $config) { // graphviz if ($config->getLogging()->getChart('bubbles')) { $graphviz = new Graphviz(); if (!$graphviz->isAvailable()) { throw new \RuntimeException('Graphviz not installed'); } } }