@@ -62,19 +62,18 @@ class PHP_CodeCoverage_Report_HTML_Renderer_Dashboard extends PHP_CodeCoverage_R
6262 */
6363 public function render (PHP_CodeCoverage_Report_Node_Directory $ node , $ file )
6464 {
65- $ classes = $ node ->getClassesAndTraits ();
66- $ isRoot = $ node ->getParent () === null ;
67-
65+ $ classes = $ node ->getClassesAndTraits ();
6866 $ template = new Text_Template (
6967 $ this ->templatePath . 'dashboard.html ' , '{{ ' , '}} '
7068 );
7169
7270 $ this ->setCommonTemplateVariables ($ template , $ node );
7371
74- $ complexity = $ this ->complexity ($ classes , $ isRoot );
75- $ coverageDistribution = $ this ->coverageDistribution ($ classes , $ isRoot );
76- $ insufficientCoverage = $ this ->insufficientCoverage ($ classes , $ isRoot );
77- $ projectRisks = $ this ->projectRisks ($ classes , $ isRoot );
72+ $ baseLink = $ node ->getId () . '/ ' ;
73+ $ complexity = $ this ->complexity ($ classes , $ baseLink );
74+ $ coverageDistribution = $ this ->coverageDistribution ($ classes );
75+ $ insufficientCoverage = $ this ->insufficientCoverage ($ classes , $ baseLink );
76+ $ projectRisks = $ this ->projectRisks ($ classes , $ baseLink );
7877
7978 $ template ->setVar (
8079 array (
@@ -95,11 +94,11 @@ public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file)
9594 /**
9695 * Returns the data for the Class/Method Complexity charts.
9796 *
98- * @param array $classes
99- * @param boolean $isRoot
97+ * @param array $classes
98+ * @param string $baseLink
10099 * @return array
101100 */
102- protected function complexity (array $ classes , $ isRoot )
101+ protected function complexity (array $ classes , $ baseLink )
103102 {
104103 $ result = array ('class ' => array (), 'method ' => array ());
105104
@@ -114,7 +113,7 @@ protected function complexity(array $classes, $isRoot)
114113 $ method ['ccn ' ],
115114 sprintf (
116115 '<a href="%s">%s</a> ' ,
117- $ this -> rebaseLink ( $ method ['link ' ], $ isRoot ),
116+ str_replace ( $ baseLink , '' , $ method ['link ' ]),
118117 $ methodName
119118 )
120119 );
@@ -125,7 +124,7 @@ protected function complexity(array $classes, $isRoot)
125124 $ class ['ccn ' ],
126125 sprintf (
127126 '<a href="%s">%s</a> ' ,
128- $ this -> rebaseLink ( $ class ['link ' ], $ isRoot ),
127+ str_replace ( $ baseLink , '' , $ class ['link ' ]),
129128 $ className
130129 )
131130 );
@@ -140,11 +139,10 @@ protected function complexity(array $classes, $isRoot)
140139 /**
141140 * Returns the data for the Class / Method Coverage Distribution chart.
142141 *
143- * @param array $classes
144- * @param boolean $isRoot
142+ * @param array $classes
145143 * @return array
146144 */
147- protected function coverageDistribution (array $ classes, $ isRoot )
145+ protected function coverageDistribution (array $ classes )
148146 {
149147 $ result = array (
150148 'class ' => array (
@@ -210,11 +208,11 @@ protected function coverageDistribution(array $classes, $isRoot)
210208 /**
211209 * Returns the classes / methods with insufficient coverage.
212210 *
213- * @param array $classes
214- * @param boolean $isRoot
211+ * @param array $classes
212+ * @param string $baseLink
215213 * @return array
216214 */
217- protected function insufficientCoverage (array $ classes , $ isRoot )
215+ protected function insufficientCoverage (array $ classes , $ baseLink )
218216 {
219217 $ leastTestedClasses = array ();
220218 $ leastTestedMethods = array ();
@@ -244,7 +242,7 @@ protected function insufficientCoverage(array $classes, $isRoot)
244242 foreach ($ leastTestedClasses as $ className => $ coverage ) {
245243 $ result ['class ' ] .= sprintf (
246244 ' <tr><td><a href="%s">%s</a></td><td class="text-right">%d%%</td></tr> ' . "\n" ,
247- $ this -> rebaseLink ( $ classes [$ className ]['link ' ], $ isRoot ),
245+ str_replace ( $ baseLink , '' , $ classes [$ className ]['link ' ]),
248246 $ className ,
249247 $ coverage
250248 );
@@ -255,7 +253,7 @@ protected function insufficientCoverage(array $classes, $isRoot)
255253
256254 $ result ['method ' ] .= sprintf (
257255 ' <tr><td><a href="%s"><abbr title="%s">%s</a></a></td><td class="text-right">%d%%</td></tr> ' . "\n" ,
258- $ this -> rebaseLink ( $ classes [$ class ]['methods ' ][$ method ]['link ' ], $ isRoot ),
256+ str_replace ( $ baseLink , '' , $ classes [$ class ]['methods ' ][$ method ]['link ' ]),
259257 $ methodName ,
260258 $ method ,
261259 $ coverage
@@ -268,11 +266,11 @@ protected function insufficientCoverage(array $classes, $isRoot)
268266 /**
269267 * Returns the project risks according to the CRAP index.
270268 *
271- * @param array $classes
272- * @param boolean $isRoot
269+ * @param array $classes
270+ * @param string $baseLink
273271 * @return array
274272 */
275- protected function projectRisks (array $ classes , $ isRoot )
273+ protected function projectRisks (array $ classes , $ baseLink )
276274 {
277275 $ classRisks = array ();
278276 $ methodRisks = array ();
@@ -304,7 +302,7 @@ protected function projectRisks(array $classes, $isRoot)
304302 foreach ($ classRisks as $ className => $ crap ) {
305303 $ result ['class ' ] .= sprintf (
306304 ' <tr><td><a href="%s">%s</a></td><td class="text-right">%d</td></tr> ' . "\n" ,
307- $ this -> rebaseLink ( $ classes [$ className ]['link ' ], $ isRoot ),
305+ str_replace ( $ baseLink , '' , $ classes [$ className ]['link ' ]),
308306 $ className ,
309307 $ crap
310308 );
@@ -315,7 +313,7 @@ protected function projectRisks(array $classes, $isRoot)
315313
316314 $ result ['method ' ] .= sprintf (
317315 ' <tr><td><a href="%s"><abbr title="%s">%s</abbr></a></td><td class="text-right">%d</td></tr> ' . "\n" ,
318- $ this -> rebaseLink ( $ classes [$ class ]['methods ' ][$ method ]['link ' ], $ isRoot ),
316+ str_replace ( $ baseLink , '' , $ classes [$ class ]['methods ' ][$ method ]['link ' ]),
319317 $ methodName ,
320318 $ method ,
321319 $ crap
@@ -333,15 +331,4 @@ protected function getActiveBreadcrumb(PHP_CodeCoverage_Report_Node $node)
333331 $ node ->getName ()
334332 );
335333 }
336-
337- /**
338- * @param string $link
339- * @param boolean $isRoot
340- * @return string
341- * @since Method available since Release 2.0.12
342- */
343- private function rebaseLink ($ link , $ isRoot )
344- {
345- return $ isRoot ? $ link : substr ($ link , strpos ($ link , '/ ' ) + 1 );
346- }
347334}
0 commit comments