1414use RobinIngelbrecht \PHPUnitCoverageTools \MinCoverage \MinCoverageRule ;
1515use RobinIngelbrecht \PHPUnitCoverageTools \MinCoverage \MinCoverageRules ;
1616use RobinIngelbrecht \PHPUnitCoverageTools \MinCoverage \ResultStatus ;
17- use SebastianBergmann \Timer \Timer ;
17+ use RobinIngelbrecht \PHPUnitCoverageTools \Timer \SystemTimer ;
18+ use RobinIngelbrecht \PHPUnitCoverageTools \Timer \Timer ;
1819use Symfony \Component \Console \Helper \FormatterHelper ;
1920
2021final class ApplicationFinishedSubscriber extends FormatterHelper implements FinishedSubscriber
@@ -25,13 +26,13 @@ public function __construct(
2526 private readonly bool $ cleanUpCloverXml ,
2627 private readonly Exitter $ exitter ,
2728 private readonly ConsoleOutput $ consoleOutput ,
29+ private readonly Timer $ timer ,
2830 ) {
2931 }
3032
3133 public function notify (Finished $ event ): void
3234 {
33- $ timer = new Timer ();
34- $ timer ->start ();
35+ $ this ->timer ->start ();
3536 /** @var string $reflectionFileName */
3637 $ reflectionFileName = (new \ReflectionClass (ClassLoader::class))->getFileName ();
3738 $ absolutePathToCloverXml = dirname ($ reflectionFileName , 3 ).'/ ' .$ this ->relativePathToCloverXml ;
@@ -51,15 +52,21 @@ public function notify(Finished $event): void
5152 if ($ this ->minCoverageRules ->hasTotalRule () && \XMLReader::ELEMENT == $ reader ->nodeType && 'metrics ' == $ reader ->name && 2 === $ reader ->depth ) {
5253 /** @var \SimpleXMLElement $node */
5354 $ node = simplexml_load_string ($ reader ->readOuterXml ());
54- $ metricTotal = CoverageMetric::fromCloverXmlNode ($ node , MinCoverageRule::TOTAL );
55+ $ metricTotal = CoverageMetric::fromCloverXmlNode (
56+ node: $ node ,
57+ forClass: MinCoverageRule::TOTAL
58+ );
5559 continue ;
5660 }
5761 if ($ this ->minCoverageRules ->hasOtherRulesThanTotalRule () && \XMLReader::ELEMENT == $ reader ->nodeType && 'class ' == $ reader ->name && 3 === $ reader ->depth ) {
5862 /** @var \SimpleXMLElement $node */
5963 $ node = simplexml_load_string ($ reader ->readInnerXml ());
6064 /** @var string $className */
6165 $ className = $ reader ->getAttribute ('name ' );
62- $ metrics [] = CoverageMetric::fromCloverXmlNode ($ node , $ className );
66+ $ metrics [] = CoverageMetric::fromCloverXmlNode (
67+ node: $ node ,
68+ forClass: $ className
69+ );
6370 }
6471 }
6572 $ reader ->close ();
@@ -78,7 +85,10 @@ public function notify(Finished $event): void
7885 metricTotal: $ metricTotal ,
7986 );
8087
81- $ this ->consoleOutput ->print ($ results , $ timer ->stop ());
88+ $ this ->consoleOutput ->print (
89+ results: $ results ,
90+ duration: $ this ->timer ->stop ()
91+ );
8292
8393 $ needsExit = !empty (array_filter (
8494 $ results ,
@@ -138,7 +148,8 @@ public static function fromConfigurationAndParameters(
138148 minCoverageRules: $ rules ,
139149 cleanUpCloverXml: $ cleanUpCloverXml ,
140150 exitter: new Exitter (),
141- consoleOutput: new ConsoleOutput (new \Symfony \Component \Console \Output \ConsoleOutput ()),
151+ consoleOutput: ConsoleOutput::create (),
152+ timer: SystemTimer::create (),
142153 );
143154 }
144155}
0 commit comments