@@ -102,47 +102,26 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL
102102 $ classStatements = 0 ;
103103 $ coveredClassStatements = 0 ;
104104 $ coveredMethods = 0 ;
105+ $ classMethods = 0 ;
105106
106107 foreach ($ class ['methods ' ] as $ methodName => $ method ) {
107- $ methodCount = 0 ;
108- $ methodLines = 0 ;
109- $ methodLinesCovered = 0 ;
108+ if ($ method ['executableLines ' ] == 0 )
109+ continue ;
110110
111+ $ classMethods ++;
112+ $ classStatements += $ method ['executableLines ' ];
113+ $ coveredClassStatements += $ method ['executedLines ' ];
114+ if ($ method ['coverage ' ] == 100 ){
115+ $ coveredMethods ++;
116+ }
117+
118+ $ methodCount = 0 ;
111119 for ($ i = $ method ['startLine ' ];
112120 $ i <= $ method ['endLine ' ];
113121 $ i ++) {
114- $ add = TRUE ;
115- $ count = 0 ;
116-
117- if (isset ($ coverage [$ i ])) {
118- if ($ coverage [$ i ] !== NULL ) {
119- $ classStatements ++;
120- $ methodLines ++;
121- } else {
122- $ add = FALSE ;
123- }
124-
125- $ count = count ($ coverage [$ i ]);
126-
127- if ($ count > 0 ) {
128- $ coveredClassStatements ++;
129- $ methodLinesCovered ++;
130- }
131- } else {
132- $ add = FALSE ;
122+ if (isset ($ coverage [$ i ]) && ($ coverage [$ i ] !== NULL )) {
123+ $ methodCount = max ($ methodCount , count ($ coverage [$ i ]));
133124 }
134-
135- $ methodCount = max ($ methodCount , $ count );
136-
137- if ($ add ) {
138- $ lines [$ i ] = array (
139- 'count ' => $ count , 'type ' => 'stmt '
140- );
141- }
142- }
143-
144- if ($ methodCount > 0 ) {
145- $ coveredMethods ++;
146125 }
147126
148127 $ lines [$ method ['startLine ' ]] = array (
@@ -188,7 +167,7 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL
188167 $ xmlFile ->appendChild ($ xmlClass );
189168
190169 $ xmlMetrics = $ xmlDocument ->createElement ('metrics ' );
191- $ xmlMetrics ->setAttribute ('methods ' , count ( $ class [ ' methods ' ]) );
170+ $ xmlMetrics ->setAttribute ('methods ' , $ classMethods );
192171 $ xmlMetrics ->setAttribute ('coveredmethods ' , $ coveredMethods );
193172 $ xmlMetrics ->setAttribute ('conditionals ' , 0 );
194173 $ xmlMetrics ->setAttribute ('coveredconditionals ' , 0 );
@@ -198,7 +177,7 @@ public function process(PHP_CodeCoverage $coverage, $target = NULL, $name = NULL
198177 );
199178 $ xmlMetrics ->setAttribute (
200179 'elements ' ,
201- count ( $ class [ ' methods ' ]) +
180+ $ classMethods +
202181 $ classStatements
203182 /* + conditionals */ );
204183 $ xmlMetrics ->setAttribute (
0 commit comments