Skip to content

Commit 343fab9

Browse files
committed
Displays optional project name instead of absolute root in HTML title tag.
1 parent 5053e44 commit 343fab9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/CodeCoverage/Report/HTML/Renderer.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ protected function setCommonTemplateVariables(Text_Template $template, PHP_CodeC
169169
$template->setVar(
170170
array(
171171
'id' => $node->getId(),
172-
'full_path' => $node->getPath(),
172+
'full_path' => $this->stripProjectPrefixFromNodePath($node),
173173
'path_to_root' => $this->getPathToRoot($node),
174174
'breadcrumbs' => $this->getBreadcrumbs($node),
175175
'date' => $this->date,
@@ -246,6 +246,25 @@ protected function stripProjectPrefixFromNodeName(PHP_CodeCoverage_Report_Node $
246246
return $node->getName();
247247
}
248248

249+
/**
250+
* An evolved version of PHP_CodeCoverage_Report_Node::getName(), which replaces
251+
* the optional absoluteRoot prefix in the node's full path, with specified
252+
* project name.
253+
* @param PHP_CodeCoverage_Report_Node $node
254+
* @return string
255+
*/
256+
protected function stripProjectPrefixFromNodePath(PHP_CodeCoverage_Report_Node $node)
257+
{
258+
if ($this->absoluteRoot) {
259+
return preg_replace(
260+
'#^' . $this->absoluteRoot . '#',
261+
$this->projectPrefix,
262+
$node->getPath());
263+
}
264+
else
265+
return $node->getPath();
266+
}
267+
249268

250269
/**
251270
* @param PHP_CodeCoverage_Report_Node $node

0 commit comments

Comments
 (0)