/** * @param $filePath * @param AnalyzerFileResult $fileResult */ public function addFileResult($filePath, AnalyzerFileResult $fileResult) { $firstSlash = strpos($filePath, '/'); if ($firstSlash === false) { $this->files[$filePath] = $fileResult; return; } $dirName = substr($filePath, 0, $firstSlash); if (isset($this->directories[$dirName])) { $directory = $this->directories[$dirName]; } else { $directory = new ResultDirectory(array_merge($this->path, array($dirName))); $this->directories[$dirName] = $directory; } $subPath = substr($filePath, $firstSlash + 1); $directory->addFileResult($subPath, $fileResult); }
/** * @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(); }