@@ -19,9 +19,55 @@ The packaged test configuration includes a small integration layer under
1919 * - ``FastForward\DevTools\PhpUnit\Event\TestSuite\ByPassfinalsStartedSubscriber ``
2020 - Enables ``DG\BypassFinals ``
2121 - Allows tests to work with final constructs.
22- * - ``FastForward\DevTools\PhpUnit\Event\TestSuite\JoliNotifExecutionFinishedSubscriber ``
23- - Sends desktop notifications
24- - Summarizes pass, failure, error, runtime, and memory data.
22+ * - ``FastForward\DevTools\PhpUnit\Event\TestSuite\JoliNotifExecutionFinishedSubscriber ``
23+ - Sends desktop notifications
24+ - Summarizes pass, failure, error, runtime, and memory data.
25+ * - ``FastForward\DevTools\PhpUnit\Coverage\CoverageSummaryLoaderInterface ``
26+ - Loads PHPUnit coverage reports
27+ - Contract for loading serialized PHP coverage data.
28+ * - ``FastForward\DevTools\PhpUnit\Coverage\CoverageSummaryLoader ``
29+ - Loads PHPUnit coverage reports
30+ - Implementation that reads ``coverage-php `` output.
31+ * - ``FastForward\DevTools\PhpUnit\Coverage\CoverageSummary ``
32+ - Represents line coverage metrics
33+ - Provides executed lines, total executable lines, and percentage calculations.
34+
35+ Coverage Report Loading
36+ -----------------------
37+
38+ DevTools provides a reusable layer for loading PHPUnit's serialized
39+ ``coverage-php `` output. This is useful when you need to extract line
40+ coverage metrics programmatically.
41+
42+ ``CoverageSummaryLoaderInterface `` defines the contract:
43+
44+ .. code-block :: php
45+
46+ namespace FastForward\DevTools\PhpUnit\Coverage;
47+
48+ interface CoverageSummaryLoaderInterface
49+ {
50+ public function load(string $coverageReportPath): CoverageSummary;
51+ }
52+
53+ ``CoverageSummaryLoader `` implements this contract:
54+
55+ .. code-block :: php
56+
57+ use FastForward\DevTools\PhpUnit\Coverage\CoverageSummaryLoader;
58+
59+ $loader = new CoverageSummaryLoader();
60+ $summary = $loader->load('public/coverage/coverage.php');
61+
62+ $summary->executedLines(); // Number of covered lines
63+ $summary->executableLines(); // Total number of executable lines
64+ $summary->percentage(); // Coverage as float (0-100)
65+ $summary->percentageAsString(); // Formatted string like "85.50%"
66+
67+ .. note ::
68+
69+ The loader expects the PHP file produced by PHPUnit's ``--coverage-php `` option.
70+ It must contain a ``SebastianBergmann\CodeCoverage\CodeCoverage `` instance.
2571
2672These classes are especially relevant when a consumer project overrides the
2773packaged ``phpunit.xml `` and wants to preserve the same runtime behavior.
0 commit comments