diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index 45b2eaca2..35f21d0bc 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -114,6 +114,11 @@ final class CodeCoverage */ private $cacheDirectory; + /** + * @var ?Directory + */ + private $cacheReport; + public function __construct(Driver $driver, Filter $filter) { $this->driver = $driver; @@ -127,7 +132,10 @@ public function __construct(Driver $driver, Filter $filter) */ public function getReport(): Directory { - return (new Builder($this->analyser()))->build($this); + if (!$this->cacheReport) { + $this->cacheReport = (new Builder($this->analyser()))->build($this); + } + return clone $this->cacheReport; } /**