@@ -109,27 +109,22 @@ public function __construct($templatePath, $charset, $generator, $date, $lowUppe
109109
110110 /**
111111 * @param integer $percent
112- * @return array
112+ * @return string
113113 */
114114 protected function getColorLevel ($ percent )
115115 {
116116 if ($ percent < $ this ->lowUpperBound ) {
117- $ color = 'scarlet_red ' ;
118- $ level = 'Lo ' ;
117+ return 'error ' ;
119118 }
120119
121120 else if ($ percent >= $ this ->lowUpperBound &&
122121 $ percent < $ this ->highLowerBound ) {
123- $ color = 'butter ' ;
124- $ level = 'Med ' ;
122+ return 'warning ' ;
125123 }
126124
127125 else {
128- $ color = 'chameleon ' ;
129- $ level = 'Hi ' ;
126+ return 'success ' ;
130127 }
131-
132- return array ($ color , $ level );
133128 }
134129
135130 /**
@@ -139,78 +134,65 @@ protected function getColorLevel($percent)
139134 */
140135 protected function renderItemTemplate (Text_Template $ template , array $ data )
141136 {
142- $ classesBar = ' ' ;
143- $ classesColor = 'snow ' ;
137+ $ classesBar = ' ' ;
144138 $ classesLevel = 'None ' ;
145139 $ classesNumber = ' ' ;
146140
147141 if (isset ($ data ['numClasses ' ]) && $ data ['numClasses ' ] > 0 ) {
148- list ($ classesColor , $ classesLevel ) = $ this ->getColorLevel (
149- $ data ['testedClassesPercent ' ]
150- );
142+ $ classesLevel = $ this ->getColorLevel ($ data ['testedClassesPercent ' ]);
151143
152144 $ classesNumber = $ data ['numTestedClasses ' ] . ' / ' .
153145 $ data ['numClasses ' ];
154146
155147 $ classesBar = $ this ->getCoverageBar (
156- $ classesColor , $ data ['testedClassesPercent ' ]
148+ $ data ['testedClassesPercent ' ]
157149 );
158150 }
159151
160152 $ methodsBar = ' ' ;
161- $ methodsColor = 'snow ' ;
162153 $ methodsLevel = 'None ' ;
163154 $ methodsNumber = ' ' ;
164155
165156 if ($ data ['numMethods ' ] > 0 ) {
166- list ($ methodsColor , $ methodsLevel ) = $ this ->getColorLevel (
167- $ data ['testedMethodsPercent ' ]
168- );
157+ $ methodsLevel = $ this ->getColorLevel ($ data ['testedMethodsPercent ' ]);
169158
170159 $ methodsNumber = $ data ['numTestedMethods ' ] . ' / ' .
171160 $ data ['numMethods ' ];
172161
173162 $ methodsBar = $ this ->getCoverageBar (
174- $ methodsColor , $ data ['testedMethodsPercent ' ]
163+ $ data ['testedMethodsPercent ' ]
175164 );
176165 }
177166
178167 $ linesBar = ' ' ;
179- $ linesColor = 'snow ' ;
180168 $ linesLevel = 'None ' ;
181169 $ linesNumber = ' ' ;
182170
183171 if ($ data ['numExecutableLines ' ] > 0 ) {
184- list ($ linesColor , $ linesLevel ) = $ this ->getColorLevel (
185- $ data ['linesExecutedPercent ' ]
186- );
172+ $ linesLevel = $ this ->getColorLevel ($ data ['linesExecutedPercent ' ]);
187173
188174 $ linesNumber = $ data ['numExecutedLines ' ] . ' / ' .
189175 $ data ['numExecutableLines ' ];
190176
191177 $ linesBar = $ this ->getCoverageBar (
192- $ linesColor , $ data ['linesExecutedPercent ' ]
178+ $ data ['linesExecutedPercent ' ]
193179 );
194180 }
195181
196182 $ template ->setVar (
197183 array (
198- 'itemClass ' => isset ($ data ['itemClass ' ]) ? $ data ['itemClass ' ] : '' ,
199184 'icon ' => isset ($ data ['icon ' ]) ? $ data ['icon ' ] : '' ,
200185 'crap ' => isset ($ data ['crap ' ]) ? $ data ['crap ' ] : '' ,
201186 'name ' => $ data ['name ' ],
202187 'lines_bar ' => $ linesBar ,
203- 'lines_color ' => $ linesColor ,
204188 'lines_executed_percent ' => $ data ['linesExecutedPercentAsString ' ],
205189 'lines_level ' => $ linesLevel ,
206190 'lines_number ' => $ linesNumber ,
207191 'methods_bar ' => $ methodsBar ,
208- 'methods_color ' => $ methodsColor ,
209192 'methods_tested_percent ' => $ data ['testedMethodsPercentAsString ' ],
210193 'methods_level ' => $ methodsLevel ,
211194 'methods_number ' => $ methodsNumber ,
212195 'classes_bar ' => $ classesBar ,
213- 'classes_color ' => $ classesColor ,
214196 'classes_tested_percent ' => isset ($ data ['testedClassesPercentAsString ' ]) ? $ data ['testedClassesPercentAsString ' ] : '' ,
215197 'classes_level ' => $ classesLevel ,
216198 'classes_number ' => $ classesNumber
@@ -225,17 +207,17 @@ protected function renderItemTemplate(Text_Template $template, array $data)
225207 * @param string $title
226208 * @param PHP_CodeCoverage_Report_Node $node
227209 */
228- protected function setCommonTemplateVariables (Text_Template $ template , $ title , PHP_CodeCoverage_Report_Node $ node = NULL )
210+ protected function setCommonTemplateVariables (Text_Template $ template , $ title , PHP_CodeCoverage_Report_Node $ node )
229211 {
230- $ link = '' ;
212+ $ navigation = '' ;
231213
232214 if ($ node !== NULL ) {
233215 $ path = $ node ->getPathAsArray ();
234216
235217 foreach ($ path as $ step ) {
236- $ link .= sprintf (
237- '%s <a href="%s.html">%s</a>' ,
238- ! empty ( $ link ) ? '/ ' : '' ,
218+ $ navigation .= sprintf (
219+ ' <li%s> <a href="%s.html">%s</a></li> ' . "\n" ,
220+ $ step === $ node ? ' class="active" ' : '' ,
239221 $ step ->getId (),
240222 $ step ->getName ()
241223 );
@@ -245,7 +227,9 @@ protected function setCommonTemplateVariables(Text_Template $template, $title, P
245227 $ template ->setVar (
246228 array (
247229 'title ' => $ title ,
248- 'link ' => $ link ,
230+ 'id ' => $ node ->getId (),
231+ 'full_path ' => $ node ->getPath (),
232+ 'navigation ' => $ navigation ,
249233 'charset ' => $ this ->charset ,
250234 'date ' => $ this ->date ,
251235 'version ' => '@package_version@ ' ,
@@ -257,11 +241,26 @@ protected function setCommonTemplateVariables(Text_Template $template, $title, P
257241 );
258242 }
259243
260- protected function getCoverageBar ($ color , $ percent )
244+ protected function getCoverageBar ($ percent )
261245 {
262- $ template = new Text_Template ($ this ->templatePath . 'coverage_bar.html ' );
246+ if ($ percent < $ this ->lowUpperBound ) {
247+ $ level = 'danger ' ;
248+ }
249+
250+ else if ($ percent >= $ this ->lowUpperBound &&
251+ $ percent < $ this ->highLowerBound ) {
252+ $ level = 'warning ' ;
253+ }
254+
255+ else {
256+ $ level = 'success ' ;
257+ }
258+
259+ $ template = new Text_Template (
260+ $ this ->templatePath . 'coverage_bar.html '
261+ );
263262
264- $ template ->setVar (array ('color ' => $ color , 'percent ' => $ percent ));
263+ $ template ->setVar (array ('level ' => $ level , 'percent ' => $ percent ));
265264
266265 return $ template ->render ();
267266 }
0 commit comments