Skip to content

Instantly share code, notes, and snippets.

@skollro
Created April 18, 2018 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skollro/978bb6c870dcd6de6af502bca293e8d2 to your computer and use it in GitHub Desktop.
Save skollro/978bb6c870dcd6de6af502bca293e8d2 to your computer and use it in GitHub Desktop.
<?php
class Temporary
{
public static function file($contents, $callback)
{
$path = tempnam(sys_get_temp_dir(), 'php_');
file_put_contents($path, $contents);
try {
return $callback($path);
} finally {
unlink($path);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment