Skip to content

Commit 261086a

Browse files
Extract method
1 parent fdd6b86 commit 261086a

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/Runner/PhptTestCase.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,7 @@ final class PhptTestCase implements SelfDescribing, Test
9090
*/
9191
public function __construct(string $filename, ?AbstractPhpProcess $phpUtil = null)
9292
{
93-
if (!is_file($filename)) {
94-
throw new Exception(
95-
sprintf(
96-
'File "%s" does not exist.',
97-
$filename
98-
)
99-
);
100-
}
93+
$this->ensureFileExists($filename);
10194

10295
$this->filename = $filename;
10396
$this->phpUtil = $phpUtil ?: AbstractPhpProcess::factory();
@@ -821,4 +814,19 @@ private function settings(bool $collectCoverage): array
821814

822815
return $settings;
823816
}
817+
818+
/**
819+
* @throws Exception
820+
*/
821+
private function ensureFileExists(string $filename): void
822+
{
823+
if (!is_file($filename)) {
824+
throw new Exception(
825+
sprintf(
826+
'File "%s" does not exist.',
827+
$filename
828+
)
829+
);
830+
}
831+
}
824832
}

0 commit comments

Comments
 (0)