File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,13 @@ abstract public function getTraits();
173
173
*/
174
174
abstract public function getFunctions ();
175
175
176
+ /**
177
+ * Returns the LOC/CLOC/NCLOC of this node.
178
+ *
179
+ * @return array
180
+ */
181
+ abstract public function getLinesOfCode ();
182
+
176
183
/**
177
184
* Returns the number of executable lines.
178
185
*
Original file line number Diff line number Diff line change @@ -87,6 +87,11 @@ class PHP_CodeCoverage_Report_Node_Directory extends PHP_CodeCoverage_Report_Nod
87
87
*/
88
88
protected $ functions ;
89
89
90
+ /**
91
+ * @var array
92
+ */
93
+ protected $ linesOfCode = NULL ;
94
+
90
95
/**
91
96
* @var integer
92
97
*/
@@ -284,6 +289,28 @@ public function getFunctions()
284
289
return $ this ->functions ;
285
290
}
286
291
292
+ /**
293
+ * Returns the LOC/CLOC/NCLOC of this node.
294
+ *
295
+ * @return array
296
+ */
297
+ public function getLinesOfCode ()
298
+ {
299
+ if ($ this ->linesOfCode === NULL ) {
300
+ $ this ->linesOfCode = array ('loc ' => 0 , 'cloc ' => 0 , 'ncloc ' => 0 );
301
+
302
+ foreach ($ this ->children as $ child ) {
303
+ $ linesOfCode = $ child ->getLinesOfCode ();
304
+
305
+ $ this ->linesOfCode ['loc ' ] += $ linesOfCode ['loc ' ];
306
+ $ this ->linesOfCode ['cloc ' ] += $ linesOfCode ['cloc ' ];
307
+ $ this ->linesOfCode ['ncloc ' ] += $ linesOfCode ['ncloc ' ];
308
+ }
309
+ }
310
+
311
+ return $ this ->linesOfCode ;
312
+ }
313
+
287
314
/**
288
315
* Returns the number of executable lines.
289
316
*
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ class PHP_CodeCoverage_Report_Node_File extends PHP_CodeCoverage_Report_Node
106
106
*/
107
107
protected $ functions = array ();
108
108
109
+ /**
110
+ * @var array
111
+ */
112
+ protected $ linesOfCode = array ();
113
+
109
114
/**
110
115
* @var integer
111
116
*/
@@ -188,6 +193,16 @@ public function getFunctions()
188
193
return $ this ->functions ;
189
194
}
190
195
196
+ /**
197
+ * Returns the LOC/CLOC/NCLOC of this node.
198
+ *
199
+ * @return array
200
+ */
201
+ public function getLinesOfCode ()
202
+ {
203
+ return $ this ->linesOfCode ;
204
+ }
205
+
191
206
/**
192
207
* Returns the number of executable lines.
193
208
*
@@ -360,6 +375,7 @@ protected function calculateStatistics()
360
375
$ this ->processClasses ($ tokens );
361
376
$ this ->processTraits ($ tokens );
362
377
$ this ->processFunctions ($ tokens );
378
+ $ this ->linesOfCode = $ tokens ->getLinesOfCode ();
363
379
unset($ tokens );
364
380
365
381
$ max = count (file ($ this ->getPath ()));
You can’t perform that action at this time.
0 commit comments