@@ -51,6 +51,16 @@ final class Directory extends AbstractNode implements \IteratorAggregate
51
51
*/
52
52
private $ linesOfCode ;
53
53
54
+ /**
55
+ * @var array
56
+ */
57
+ private $ paths ;
58
+
59
+ /**
60
+ * @var array
61
+ */
62
+ private $ branches ;
63
+
54
64
/**
55
65
* @var int
56
66
*/
@@ -106,6 +116,26 @@ final class Directory extends AbstractNode implements \IteratorAggregate
106
116
*/
107
117
private $ numTestedFunctions = -1 ;
108
118
119
+ /**
120
+ * @var int
121
+ */
122
+ private $ numPaths = -1 ;
123
+
124
+ /**
125
+ * @var int
126
+ */
127
+ private $ numTestedPaths = -1 ;
128
+
129
+ /**
130
+ * @var int
131
+ */
132
+ private $ numBranches = -1 ;
133
+
134
+ /**
135
+ * @var int
136
+ */
137
+ private $ numTestedBranches = -1 ;
138
+
109
139
/**
110
140
* Returns the number of files in/under this node.
111
141
*/
@@ -160,6 +190,8 @@ public function addFile(string $name, array $coverageData, array $testData, bool
160
190
161
191
$ this ->numExecutableLines = -1 ;
162
192
$ this ->numExecutedLines = -1 ;
193
+ $ this ->numPaths = -1 ;
194
+ $ this ->numTestedPaths = -1 ;
163
195
164
196
return $ file ;
165
197
}
@@ -424,4 +456,106 @@ public function getNumTestedFunctions(): int
424
456
425
457
return $ this ->numTestedFunctions ;
426
458
}
459
+
460
+ /**
461
+ * Returns the paths of this node.
462
+ */
463
+ public function getPaths (): array
464
+ {
465
+ if ($ this ->paths === null ) {
466
+ $ this ->paths = [];
467
+
468
+ foreach ($ this ->children as $ child ) {
469
+ $ this ->paths = \array_merge (
470
+ $ this ->paths ,
471
+ $ child ->getPaths ()
472
+ );
473
+ }
474
+ }
475
+
476
+ return $ this ->paths ;
477
+ }
478
+
479
+ /**
480
+ * Returns the branches of this node.
481
+ */
482
+ public function getBranches (): array
483
+ {
484
+ if ($ this ->branches === null ) {
485
+ $ this ->branches = [];
486
+
487
+ foreach ($ this ->children as $ child ) {
488
+ $ this ->branches = \array_merge (
489
+ $ this ->branches ,
490
+ $ child ->getBranches ()
491
+ );
492
+ }
493
+ }
494
+
495
+ return $ this ->branches ;
496
+ }
497
+
498
+ /**
499
+ * Returns the number of paths.
500
+ */
501
+ public function getNumPaths (): int
502
+ {
503
+ if ($ this ->numPaths === -1 ) {
504
+ $ this ->numPaths = 0 ;
505
+
506
+ foreach ($ this ->children as $ child ) {
507
+ $ this ->numPaths += $ child ->getNumPaths ();
508
+ }
509
+ }
510
+
511
+ return $ this ->numPaths ;
512
+ }
513
+
514
+ /**
515
+ * Returns the number of tested paths.
516
+ */
517
+ public function getNumTestedPaths (): int
518
+ {
519
+ if ($ this ->numTestedPaths === -1 ) {
520
+ $ this ->numTestedPaths = 0 ;
521
+
522
+ foreach ($ this ->children as $ child ) {
523
+ $ this ->numTestedPaths += $ child ->getNumTestedPaths ();
524
+ }
525
+ }
526
+
527
+ return $ this ->numTestedPaths ;
528
+ }
529
+
530
+ /**
531
+ * Returns the number of branches.
532
+ */
533
+ public function getNumBranches (): int
534
+ {
535
+ if ($ this ->numBranches === -1 ) {
536
+ $ this ->numBranches = 0 ;
537
+
538
+ foreach ($ this ->children as $ child ) {
539
+ $ this ->numBranches += $ child ->getNumBranches ();
540
+ }
541
+ }
542
+
543
+ return $ this ->numBranches ;
544
+ }
545
+
546
+ /**
547
+ * Returns the number of tested branches.
548
+ */
549
+ public function getNumTestedBranches (): int
550
+ {
551
+ if ($ this ->numTestedBranches === -1 ) {
552
+ $ this ->numTestedBranches = 0 ;
553
+
554
+ foreach ($ this ->children as $ child ) {
555
+ $ this ->numTestedBranches += $ child ->getNumTestedBranches ();
556
+ }
557
+ }
558
+
559
+ return $ this ->numTestedBranches ;
560
+ }
427
561
}
0 commit comments