From f3698c1b06fb78560777a6a8f915292c05585692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 1 Dec 2022 12:48:11 +0100 Subject: [PATCH] Fix: Move responsibility to named constructor --- test/Util/State.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/test/Util/State.php b/test/Util/State.php index 588f9dd3..62353463 100644 --- a/test/Util/State.php +++ b/test/Util/State.php @@ -15,25 +15,26 @@ final class State { - private File $composerJsonFile; - private File $composerLockFile; - - private function __construct(private Directory $directory) - { - $this->composerJsonFile = File::fromPath(\sprintf( - '%s/composer.json', - $directory->path(), - )); - - $this->composerLockFile = File::fromPath(\sprintf( - '%s/composer.lock', - $directory->path(), - )); + private function __construct( + private Directory $directory, + private File $composerJsonFile, + private File $composerLockFile, + ) { } public static function fromDirectory(Directory $directory): self { - return new self($directory); + return new self( + $directory, + File::fromPath(\sprintf( + '%s/composer.json', + $directory->path(), + )), + File::fromPath(\sprintf( + '%s/composer.lock', + $directory->path(), + )), + ); } public function directory(): Directory