From d365d1e8a4649b6018f9190a107d0d7c873c3725 Mon Sep 17 00:00:00 2001 From: Raphael Stolt Date: Tue, 14 May 2024 19:44:37 +0200 Subject: [PATCH] Adds minor code optimisation --- app/Domain/PackageAnalyser.php | 6 +----- app/Domain/ReportWriter.php | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/Domain/PackageAnalyser.php b/app/Domain/PackageAnalyser.php index 9cdd275..bf8ea2c 100644 --- a/app/Domain/PackageAnalyser.php +++ b/app/Domain/PackageAnalyser.php @@ -12,8 +12,6 @@ class PackageAnalyser { - private string $directoryToAnalyse; - private array $steps; private array $stepIds; @@ -23,10 +21,8 @@ class PackageAnalyser /** * @throws NonExistentPackageDirectory */ - public function __construct(string $directoryToAnalyse) + public function __construct(readonly string $directoryToAnalyse) { - $this->directoryToAnalyse = $directoryToAnalyse; - if (! file_exists($directoryToAnalyse)) { $exceptionMessage = sprintf("Provided package directory '%s' does not exist.", $directoryToAnalyse); throw new NonExistentPackageDirectory($exceptionMessage); diff --git a/app/Domain/ReportWriter.php b/app/Domain/ReportWriter.php index 5df8f13..2e12eb2 100644 --- a/app/Domain/ReportWriter.php +++ b/app/Domain/ReportWriter.php @@ -13,13 +13,10 @@ class ReportWriter private string $directoryAnalysed; - private string $outputDirectory; - - public function __construct(PackageAnalyser $analyser, string $outputDirectory) + public function __construct(PackageAnalyser $analyser, readonly string $outputDirectory) { $this->analyseSteps = $analyser->getSteps(); $this->directoryAnalysed = $analyser->getDirectoryToAnalyse(); - $this->outputDirectory = $outputDirectory; } public function write(): bool