/** * @param string * @param string * @param string * @return File */ public static function createTempFile($prefix = '', $suffix = '', $inDir = '/tmp', $deleteOnExit = true) { if (($file = tempnam($inDir, $prefix) . $suffix) === false) { throw new IOException('Failed to create temporary file ' . $file); } $file = new File($file); @$file->touch(); @$file->chmod(0664); if ($deleteOnExit) { $file->deleteOnExit(); } return $file; }