Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed exception when temporary cannot be create #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
final class RuntimeException extends \RuntimeException implements ExceptionInterface
{
/**
* @param string $file
* @param string $dir
* @return self
*/
public static function unableToCreateTemporaryFile($file)
public static function unableToCreateTemporaryFile($dir)
{
return new self(sprintf('Could not create temporary file "%s"', $file));
return new self(sprintf('Could not create temporary file in directory "%s"', $dir));
}
}
2 changes: 1 addition & 1 deletion src/FileWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function writeFile($file, $content, $chmod = 0666)
$tmp = tempnam($dir, 'wsw');

if ($tmp === false) {
throw Exception\RuntimeException::unableToCreateTemporaryFile($tmp);
throw Exception\RuntimeException::unableToCreateTemporaryFile($dir);
}

if (file_put_contents($tmp, $content) === false) {
Expand Down
6 changes: 3 additions & 3 deletions test/Exception/RuntimeExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class RuntimeExceptionTest extends TestCase
{
public function testException()
{
$file = uniqid('file_', true);
$exception = RuntimeException::unableToCreateTemporaryFile($file);
$dir = uniqid('dir_', true);
$exception = RuntimeException::unableToCreateTemporaryFile($dir);

self::assertInstanceOf(RuntimeException::class, $exception);
self::assertContains($file, $exception->getMessage());
self::assertContains($dir, $exception->getMessage());
}
}