예제 #1
0
 /**
  * Determines the PHPMD error score of an analysis. The score is the sum of all the error priorities reported
  * in the analysis. 
  * 
  * @param Analysis $analysis
  * 
  * @return int
  */
 protected function getAnalysisScore(Analysis $analysis)
 {
     $score = 0;
     foreach ($analysis->getPHPMDResults()->getErrors() as $file) {
         foreach ($file as $violation) {
             $score += (int) $violation['priority'];
         }
     }
     return $score;
 }
예제 #2
0
 /**
  * Marks an analysis as viewed by setting its "new" flag to false.
  * 
  * @param Analysis $analysis
  */
 protected function markViewedAnalysis(Analysis $analysis)
 {
     $analysis->setNew(false);
     $this->doctrine->getManager()->flush();
 }
예제 #3
0
 /**
  * Saves the results of the analysis.
  * 
  * @param Project $project
  * @param DependencyResponse $dependencyResults
  * @param PHPMDResponse $phpMDResults
  */
 protected function saveResults(Project $project, DependencyResponse $dependencyResults, PHPMDResponse $phpMDResults)
 {
     $analysis = new Analysis();
     $analysis->setProject($project)->setCreated()->setDependencyResults($dependencyResults)->setPHPMDResults($phpMDResults);
     $entityManager = $this->doctrine->getManager();
     $entityManager->persist($analysis);
     $entityManager->flush();
 }