/** * @param AnalyzerResult $result */ public function generate(AnalyzerResult $result) { $tree = new ResultDirectory(); $files = $result->getPerFile(); foreach ($files as $fileResult) { $relativePath = PathNormalizer::makeRelativeTo($fileResult->getFile(), $this->sourceDir); $tree->addFileResult($relativePath, $fileResult); } $this->renderDirectoryRecursively($tree); }
/** * @param array $trace * * @return array */ private function traceRelativePath(array $trace) { if (!$this->sourceDir) { return $trace; } foreach ($trace as $key => &$frame) { if (isset($frame['file'])) { $frame['file'] = PathNormalizer::makeRelativeTo($frame['file'], $this->sourceDir); } } return $trace; }
/** * @param AnalyzerFileResult $fileResult */ private function renderFile(AnalyzerFileResult $fileResult) { $tombstonesList = $this->renderTombstonesList($fileResult); $sourceCode = $this->formatSourceCode($fileResult); $relativeFilePath = PathNormalizer::makeRelativeTo($fileResult->getFile(), $this->sourceDir); $this->fileTemplate->setVar(array('path_to_root' => './' . str_repeat('../', substr_count($relativeFilePath, '/')), 'full_path' => $fileResult->getFile(), 'breadcrumb' => $this->renderBreadcrumb($relativeFilePath), 'tombstones_list' => $tombstonesList, 'source_code' => $sourceCode, 'date' => date('r'), 'version' => Application::VERSION)); $reportFile = $this->reportDir . DIRECTORY_SEPARATOR . $relativeFilePath . '.html'; $reportDir = dirname($reportFile); if (!is_dir($reportDir)) { mkdir($reportDir, 0777, true); } $this->fileTemplate->renderTo($reportFile); }
/** * @param string $label * @param string $fileName * @param int $line * * @return string */ private function linkTombstoneSource($label, $fileName, $line) { $relativePath = PathNormalizer::makeRelativeTo($fileName, $this->sourceDir); return sprintf('<a href="./%s.html#%s">%s</a>', $relativePath, $line, $label); }
/** * @test * @dataProvider getTestCasesForKeepingPath */ public function makeRelativeTo_pathHasDifferentBase_returnSamePath($path, $baseDir) { $returnValue = PathNormalizer::makeRelativeTo($path, $baseDir); $this->assertEquals($path, $returnValue); }
/** * @param string $path * * @return string */ private function normalizeAndRelativePath($path) { $path = PathNormalizer::normalizeDirectorySeparator($path); return PathNormalizer::makeRelativeTo($path, $this->sourceDir); }