/** * Parses the analysis dependency results and generates the dependency graph nodes and legend in a format * that it will be used for rendering. * * @param DependencyResponse $dependencyResponse * * @return array * On the first key will be placed the nodes and on the second the legend. The method was designed to be used * with list. */ private function computeGraphNodesAndLegend(DependencyResponse $dependencyResponse) { $components = $dependencyResponse->getConnectedComponents(); $modulesNr = count($dependencyResponse->getModules()); $nodes = array(); $legend = array(); $index = 0; foreach ($components as $component) { // Every component will have a unique color. $componentColor = $this->helper->generateRandomColor(); foreach ($component as $vertex) { $nodes[$vertex] = array('id' => Settings::GRAPH_NODE_ID_PREFIX . $index, 'label' => $vertex, 'size' => Settings::GRAPH_NODE_SIZE, 'x' => $index, 'y' => $this->helper->generateRandomNumber($modulesNr), 'color' => $componentColor); $index++; } $legend[] = array('label' => implode(', ', $component), 'color' => $componentColor); } return array($nodes, $legend); }
/** * Parses the PHPMD errors into user-readable information. * * @param array $errors * * @return array */ private function computeAnalysisTable(array $errors) { $table = array(); foreach ($errors as $filename => $file) { foreach ($file as $violation) { $priority = array('code' => $violation['priority'], 'color' => $this->helper->generateColorForCss(self::$priorityColors[$violation['priority']])); $rule = array('name' => $violation['rule'], 'url' => $this->helper->filterUrl($violation['url'])); $lines = $violation['beginline'] . ':' . $violation['endline']; $table[$filename][] = array('priority' => $priority, 'ruleset' => self::$ruleLabels[$violation['ruleset']], 'rule' => $rule, 'lines' => $lines, 'message' => $violation['message']); } } return $table; }