Inheritance: extends Symfony\Component\EventDispatcher\Event
 public function onMutationsDone(\Hal\MutaTesting\Event\MutationsDoneEvent $event)
 {
     $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../../../Resources/views/');
     $twig = new \Twig_Environment($loader, array());
     $diff = new \Hal\MutaTesting\Diff\DiffHtml();
     $serviceFile = new \Hal\MutaTesting\Mutation\Consolidation\SourceFileService($event->getMutations());
     $serviceTotal = new \Hal\MutaTesting\Mutation\Consolidation\TotalService($event->getMutations());
     // total
     $total = (object) array('score' => $serviceTotal->getScore(), 'scoreStep' => ceil($serviceTotal->getScore() / 25) * 25, 'survivors' => $serviceTotal->getSurvivors()->count(), 'mutants' => $serviceTotal->getMutants()->count());
     // by file
     $byFile = array();
     $files = $serviceFile->getAvailableFiles();
     foreach ($files as $file) {
         $byFile[$file] = (object) array('score' => $serviceFile->getScore($file), 'scoreStep' => ceil($serviceFile->getScore($file) / 25) * 25, 'survivors' => $serviceFile->getSurvivors($file)->count(), 'mutants' => $serviceFile->getMutants($file)->count(), 'survivedMutations' => array());
     }
     // by file, with diff
     foreach ($event->getMutations() as $mutation) {
         $src = $mutation->getSourceFile();
         foreach ($mutation->getMutations()->getSurvivors()->all() as $survivor) {
             $byFile[$src]->survivedMutations[] = (object) array('mutant' => $survivor, 'diff' => $diff->diff($mutation->getTokens()->asString(), $survivor->getTokens()->asString()));
         }
     }
     // render html
     $html = $twig->render('report.html.twig', array('files' => $byFile, 'total' => $total, 'units' => $this->units));
     // write file
     file_put_contents($this->filename, $html);
     $this->output->writeln(sprintf('<info>file "%s" created', $this->filename));
 }
 public function onMutationsDone(\Hal\MutaTesting\Event\MutationsDoneEvent $event)
 {
     $this->output->writeln('');
     $this->output->writeln('');
     $this->output->writeln('Result:');
     // total
     $service = new \Hal\MutaTesting\Mutation\Consolidation\TotalService($event->getMutations());
     switch (true) {
         case $service->getScore() > 80:
             $color = 'info';
             break;
         case $service->getSurvivors()->count() > 50:
             $color = 'warning';
             break;
         default:
             $color = 'error';
             break;
     }
     $this->output->writeln(sprintf("\t" . '<%2$s>score: %1$s%%</%2$s>', $service->getScore(), $color));
     $this->output->writeln(sprintf("\t%d mutants.", $service->getMutants()->count()));
     $this->output->writeln(sprintf("\t%d survivors.", $service->getSurvivors()->count()));
 }
 public function onMutationsDone(\Hal\MutaTesting\Event\MutationsDoneEvent $event)
 {
     $text = '';
     $found = 0;
     $nbMutants = 0;
     $diff = new \SebastianBergmann\Diff\Diff();
     foreach ($event->getMutations() as $mutation) {
         $nbMutants += sizeof($mutation->getMutations());
         foreach ($mutation->getMutations() as $mutated) {
             $unit = $mutated->getUnit();
             if ($unit->getNumOfFailures() == 0 && $unit->getNumOfErrors() == 0) {
                 $found++;
                 $text .= PHP_EOL . PHP_EOL;
                 $text .= sprintf('    Mutation survived in %s', $mutation->getSourceFile());
                 $text .= "\t" . str_replace(PHP_EOL, PHP_EOL . "\t", $diff->diff($mutation->getTokens()->asString(), $mutated->getTokens()->asString()));
             }
         }
     }
     // write file
     file_put_contents($this->filename, $text);
     $this->output->writeln(sprintf('<info>file "%s" created', $this->filename));
 }