29
29
use SebastianBergmann \CodeCoverage \StaticAnalysis \CachingFileAnalyser ;
30
30
use SebastianBergmann \CodeCoverage \StaticAnalysis \FileAnalyser ;
31
31
use SebastianBergmann \CodeCoverage \StaticAnalysis \ParsingFileAnalyser ;
32
+ use SebastianBergmann \CodeCoverage \Test \Target \MapBuilder ;
33
+ use SebastianBergmann \CodeCoverage \Test \Target \Mapper ;
34
+ use SebastianBergmann \CodeCoverage \Test \Target \TargetCollection ;
35
+ use SebastianBergmann \CodeCoverage \Test \Target \ValidationResult ;
32
36
use SebastianBergmann \CodeCoverage \Test \TestSize \TestSize ;
33
37
use SebastianBergmann \CodeCoverage \Test \TestStatus \TestStatus ;
34
38
use SebastianBergmann \CodeUnitReverseLookup \Wizard ;
@@ -47,6 +51,7 @@ final class CodeCoverage
47
51
private readonly Driver $ driver ;
48
52
private readonly Filter $ filter ;
49
53
private readonly Wizard $ wizard ;
54
+ private ?Mapper $ targetMapper = null ;
50
55
private bool $ checkForUnintentionallyCoveredCode = false ;
51
56
private bool $ ignoreDeprecatedCode = false ;
52
57
private ?string $ currentId = null ;
@@ -348,6 +353,11 @@ public function detectsDeadCode(): bool
348
353
return $ this ->driver ->detectsDeadCode ();
349
354
}
350
355
356
+ public function validate (TargetCollection $ targets ): ValidationResult
357
+ {
358
+ return $ targets ->validate ($ this ->targetMapper ());
359
+ }
360
+
351
361
/**
352
362
* @throws ReflectionException
353
363
* @throws UnintentionallyCoveredCodeException
@@ -566,6 +576,19 @@ private function processUnintentionallyCoveredUnits(array $unintentionallyCovere
566
576
return $ processed ;
567
577
}
568
578
579
+ private function targetMapper (): Mapper
580
+ {
581
+ if ($ this ->targetMapper !== null ) {
582
+ return $ this ->targetMapper ;
583
+ }
584
+
585
+ $ this ->targetMapper = new Mapper (
586
+ (new MapBuilder )->build ($ this ->filter , $ this ->analyser ()),
587
+ );
588
+
589
+ return $ this ->targetMapper ;
590
+ }
591
+
569
592
private function analyser (): FileAnalyser
570
593
{
571
594
if ($ this ->analyser !== null ) {
0 commit comments