Ejemplo n.º 1
0
 /**
  * Computes the PHPMD analysis data in order to be rendered in a table.
  * 
  * @param Analysis $analysis
  * 
  * @return array
  * 
  * @throws AnalysesParsersException
  */
 public function forAnalysisTable(Analysis $analysis)
 {
     // Validate the arguments and throw the corresponding errors if there are problems.
     if ($this->isResultEmpty($analysis)) {
         throw new AnalysesParsersException('Analysis with empty PHPMD results provided!', AnalysesParsersException::EMPTY_RESULT_ERROR_CODE);
     }
     // Try to fetch the data from the cache firstly.
     if ($data = $this->cacheManager->get(__FUNCTION__, self::NAME, $analysis)) {
         return $data;
     }
     $errors = $analysis->getPHPMDResults()->getErrors();
     $data = $this->computeAnalysisTable($errors);
     // Save the computed data in the cache.
     $this->cacheManager->set($data, __FUNCTION__, self::NAME, $analysis);
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * Parses the dependency results in a format needed by the dependency graph renderer.
  * 
  * @param Analysis $analysis
  * 
  * @return array
  * 
  * @throws AnalysesParsersException
  */
 public function forAnalysisGraph(Analysis $analysis)
 {
     // Validate the arguments and throw the corresponding errors if there are problems.
     if ($this->isResultEmpty($analysis)) {
         throw new AnalysesParsersException('Analysis with empty dependency results provided!', AnalysesParsersException::EMPTY_RESULT_ERROR_CODE);
     }
     // Try to fetch the data from the cache. If it isn't found there, proceed with generating it.
     if ($data = $this->cacheManager->get(__FUNCTION__, self::NAME, $analysis)) {
         return $data;
     }
     $dependencyResponse = $analysis->getDependencyResults();
     list($nodes, $legend) = $this->computeGraphNodesAndLegend($dependencyResponse);
     $edges = $this->computeGraphEdges($dependencyResponse, $nodes);
     $data = array('data' => array('nodes' => array_values($nodes), 'edges' => $edges), 'legend' => $legend);
     // Save the data to the cache.
     $this->cacheManager->set($data, __FUNCTION__, self::NAME, $analysis);
     return $data;
 }