private function getFileFromStream($directory, $stream)
    {
        $file = \tempnam($directory, '');
        $target = \fopen($file, 'w');
        if (0 === \stream_copy_to_stream($stream, $target)) {
            throw new \RuntimeException('Failed to write stream to file');
        }
        \fclose($target);

        return \basename($file);
    }
private function getFileFromStream($directory, $stream)
    {
        $file = \tempnam($directory, '');
        $target = \fopen($file, 'w');
        if (0 === \stream_copy_to_stream($stream, $target)) {
            throw new \RuntimeException('Failed to write stream to file');
        }
        \fclose($target);

        return \basename($file);
    }
private function getFileFromStream ( $ directory , $ stream ) { $ file = \ tempnam ( $ directory , '' ) ; $ target = \ fopen ( $ file , 'w' ) ; if ( 0 === \ stream_copy_to_stream ( $ stream , $ target ) ) { throw new \ RuntimeException ( 'Failed to write stream to file' ) ; } \ fclose ( $ target ) ; return \ basename ( $ file ) ; }
Generated a file in a directory from a stream.

@param string   $directory Targeted directory
@param resource $stream    Stream containing file contents

@return string Name of file generated
Generated a file in a directory from a stream .