Skip to content

Commit

Permalink
Fix: Move responsibility to named constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 1, 2022
1 parent bb4c645 commit f3698c1
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions test/Util/State.php
Expand Up @@ -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
Expand Down

0 comments on commit f3698c1

Please sign in to comment.