Created
April 18, 2018 13:23
-
-
Save skollro/978bb6c870dcd6de6af502bca293e8d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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