private static function writeStream(StreamInterface $stream, $path)
    {
        $dir = dirname($path);

        if (!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }

        $handle = fopen($path, 'wb+');

        if (false === $handle) {
            throw new RuntimeException('Unable to write to designated path');
        }

        $stream->rewind();

        while (!$stream->eof()) {
            fwrite($handle, $stream->read(4096));
        }

        fclose($handle);
    }
private static function writeStream(StreamInterface $stream, $path)
    {
        $dir = dirname($path);

        if (!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }

        $handle = fopen($path, 'wb+');

        if (false === $handle) {
            throw new RuntimeException('Unable to write to designated path');
        }

        $stream->rewind();

        while (!$stream->eof()) {
            fwrite($handle, $stream->read(4096));
        }

        fclose($handle);
    }
private static function writeStream ( StreamInterface $ stream , $ path ) { $ dir = dirname ( $ path ) ; if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0777 , true ) ; } $ handle = fopen ( $ path , 'wb+' ) ; if ( false === $ handle ) { throw new RuntimeException ( 'Unable to write to designated path' ) ; } $ stream -> rewind ( ) ; while ( ! $ stream -> eof ( ) ) { fwrite ( $ handle , $ stream -> read ( 4096 ) ) ; } fclose ( $ handle ) ; }
Write the stream to the given path.

@param StreamInterface $stream
@param string          $path
Write the stream to the given path .