@@ -99,93 +99,43 @@ public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file, $tit
99
99
*/
100
100
protected function renderItem (PHP_CodeCoverage_Report_Node $ item , $ total = FALSE )
101
101
{
102
- $ template = new Text_Template (
103
- $ this ->templatePath . 'directory_item.html '
102
+ $ data = array (
103
+ 'numClasses ' => $ item ->getNumClasses (),
104
+ 'numTestedClasses ' => $ item ->getNumTestedClasses (),
105
+ 'numMethods ' => $ item ->getNumMethods (),
106
+ 'numTestedMethods ' => $ item ->getNumTestedMethods (),
107
+ 'linesExecutedPercent ' => $ item ->getLineExecutedPercent (FALSE ),
108
+ 'linesExecutedPercentAsString ' => $ item ->getLineExecutedPercent (),
109
+ 'numExecutedLines ' => $ item ->getNumExecutedLines (),
110
+ 'numExecutableLines ' => $ item ->getNumExecutableLines (),
111
+ 'testedMethodsPercent ' => $ item ->getTestedMethodsPercent (FALSE ),
112
+ 'testedMethodsPercentAsString ' => $ item ->getTestedMethodsPercent (),
113
+ 'testedClassesPercent ' => $ item ->getTestedClassesPercent (FALSE ),
114
+ 'testedClassesPercentAsString ' => $ item ->getTestedClassesPercent ()
104
115
);
105
116
106
117
if ($ total ) {
107
- $ icon = '' ;
108
- $ itemClass = 'coverDirectory ' ;
109
- $ name = 'Total ' ;
118
+ $ data ['itemClass ' ] = 'coverDirectory ' ;
119
+ $ data ['name ' ] = 'Total ' ;
110
120
} else {
111
- $ name = sprintf (
121
+ $ data [ ' name ' ] = sprintf (
112
122
'<a href="%s.html">%s</a> ' ,
113
123
$ item ->getId (),
114
124
$ item ->getName ()
115
125
);
116
126
117
127
if ($ item instanceof PHP_CodeCoverage_Report_Node_Directory) {
118
- $ icon = '<img alt="directory" src="directory.png"/> ' ;
119
- $ itemClass = 'coverDirectory ' ;
128
+ $ data [ ' icon ' ] = '<img alt="directory" src="directory.png"/> ' ;
129
+ $ data [ ' itemClass ' ] = 'coverDirectory ' ;
120
130
} else {
121
- $ icon = '<img alt="file" src="file.png"/> ' ;
122
- $ itemClass = 'coverFile ' ;
131
+ $ data [ ' icon ' ] = '<img alt="file" src="file.png"/> ' ;
132
+ $ data [ ' itemClass ' ] = 'coverFile ' ;
123
133
}
124
134
}
125
135
126
- $ numClasses = $ item ->getNumClasses ();
127
- $ testedClassesPercent = floor ($ item ->getTestedClassesPercent (FALSE ));
128
-
129
- if ($ numClasses > 0 ) {
130
- list ($ classesColor , $ classesLevel ) = $ this ->getColorLevel (
131
- $ testedClassesPercent
132
- );
133
-
134
- $ classesNumber = $ item ->getNumTestedClasses () . ' / ' . $ numClasses ;
135
- } else {
136
- $ classesColor = 'snow ' ;
137
- $ classesLevel = 'None ' ;
138
- $ classesNumber = ' ' ;
139
- }
140
-
141
- $ numMethods = $ item ->getNumMethods ();
142
- $ testedMethodsPercent = floor ($ item ->getTestedMethodsPercent (FALSE ));
143
-
144
- if ($ numMethods > 0 ) {
145
- list ($ methodsColor , $ methodsLevel ) = $ this ->getColorLevel (
146
- $ testedMethodsPercent
147
- );
148
-
149
- $ methodsNumber = $ item ->getNumTestedMethods () . ' / ' . $ numMethods ;
150
- } else {
151
- $ methodsColor = 'snow ' ;
152
- $ methodsLevel = 'None ' ;
153
- $ methodsNumber = ' ' ;
154
- }
155
-
156
- $ linesExecutedPercent = floor ($ item ->getLineExecutedPercent (FALSE ));
157
-
158
- list ($ linesColor , $ linesLevel ) = $ this ->getColorLevel (
159
- $ linesExecutedPercent
136
+ return $ this ->renderItemTemplate (
137
+ new Text_Template ($ this ->templatePath . 'directory_item.html ' ),
138
+ $ data
160
139
);
161
-
162
- $ template ->setVar (
163
- array (
164
- 'itemClass ' => $ itemClass ,
165
- 'icon ' => $ icon ,
166
- 'name ' => $ name ,
167
- 'lines_color ' => $ linesColor ,
168
- 'lines_executed_width ' => $ linesExecutedPercent ,
169
- 'lines_not_executed_width ' => 100 - $ linesExecutedPercent ,
170
- 'lines_executed_percent ' => $ item ->getLineExecutedPercent (),
171
- 'lines_level ' => $ linesLevel ,
172
- 'num_executed_lines ' => $ item ->getNumExecutedLines (),
173
- 'num_executable_lines ' => $ item ->getNumExecutableLines (),
174
- 'methods_color ' => $ methodsColor ,
175
- 'methods_tested_width ' => $ testedMethodsPercent ,
176
- 'methods_not_tested_width ' => 100 - $ testedMethodsPercent ,
177
- 'methods_tested_percent ' => $ item ->getTestedMethodsPercent (),
178
- 'methods_level ' => $ methodsLevel ,
179
- 'methods_number ' => $ methodsNumber ,
180
- 'classes_color ' => $ classesColor ,
181
- 'classes_tested_width ' => $ testedClassesPercent ,
182
- 'classes_not_tested_width ' => 100 - $ testedClassesPercent ,
183
- 'classes_tested_percent ' => $ item ->getTestedClassesPercent (),
184
- 'classes_level ' => $ classesLevel ,
185
- 'classes_number ' => $ classesNumber
186
- )
187
- );
188
-
189
- return $ template ->render ();
190
140
}
191
141
}
0 commit comments