/**
  * @param AnalyzerFileResult $fileResult
  *
  * @return string
  */
 private function formatSourceCode(AnalyzerFileResult $fileResult)
 {
     $deadLines = array();
     $undeadLines = array();
     foreach ($fileResult->getDead() as $tombstone) {
         $deadLines[] = $tombstone->getLine();
     }
     foreach ($fileResult->getUndead() as $tombstone) {
         $undeadLines[] = $tombstone->getLine();
     }
     $formattedCode = '';
     $i = 0;
     $code = PhpFileFormatter::loadFile($fileResult->getFile());
     $lineTemplate = '<tr class="%s"><td class="number"><div align="right"><a name="%d"></a><a href="#%d">%d</a></div></td><td class="codeLine">%s</td></tr>';
     foreach ($code as $codeLine) {
         ++$i;
         $class = 'default';
         if (in_array($i, $undeadLines)) {
             $class = 'danger icon-vampire';
         } else {
             if (in_array($i, $deadLines)) {
                 $class = 'success icon-cross';
             }
         }
         $formattedCode .= sprintf($lineTemplate, $class, $i, $i, $i, $codeLine);
     }
     return $formattedCode;
 }
 /**
  * @param AnalyzerFileResult $fileResult
  *
  * @return string
  */
 private function renderDeletedTombstones(AnalyzerFileResult $fileResult)
 {
     $itemList = '';
     foreach ($fileResult->getDeleted() as $vampire) {
         $this->deletedTemplate->setVar(array('path_to_root' => './', 'tombstone' => (string) $vampire->getTombstone(), 'line' => $vampire->getLine(), 'method' => $vampire->getMethod(), 'last_call' => TimePeriodFormatter::formatAge($vampire->getInvocationDate())));
         $itemList .= $this->deletedTemplate->render();
     }
     return $itemList;
 }
 /**
  * @param string $name
  * @param string $link
  * @param AnalyzerFileResult|ResultDirectory $result
  *
  * @return string
  */
 private function renderDirectoryItem($name, $link, $result)
 {
     $deadCount = $result->getDeadCount();
     $undeadCount = $result->getUndeadCount();
     $totalCount = $deadCount + $undeadCount;
     $class = 'success';
     if ($undeadCount) {
         if ($undeadCount < $totalCount) {
             $class = 'warning';
         } else {
             $class = 'danger';
         }
     }
     $bar = $this->renderBar($deadCount, $totalCount);
     $this->directoryItemTemplate->setVar(array('name' => $name, 'icon' => $result instanceof AnalyzerFileResult ? 'file' : 'folder-open', 'link' => $link, 'class' => $class, 'bar' => $bar, 'total' => $totalCount, 'numDead' => $deadCount, 'numUndead' => $undeadCount));
     return $this->directoryItemTemplate->render();
 }