protected function writeStream(string $path): void
    {
        // Attempt to open the path specified
        $handle = fopen($path, 'wb+');

        // If the handler failed to open
        if (false === $handle) {
            // Throw a runtime exception
            throw new RuntimeException(
                'Unable to write to designated path'
            );
        }

        // Get the stream
        $stream = $this->getStream();
        // Rewind the stream
        $stream->rewind();

        // While the end of file hasn't been reached
        while (! $stream->eof()) {
            // Write the stream's contents to the handler
            fwrite($handle, $stream->read(4096));
        }

        // Close the file path
        fclose($handle);
    }
protected function writeStream(string $path): void
    {
        // Attempt to open the path specified
        $handle = fopen($path, 'wb+');

        // If the handler failed to open
        if (false === $handle) {
            // Throw a runtime exception
            throw new RuntimeException(
                'Unable to write to designated path'
            );
        }

        // Get the stream
        $stream = $this->getStream();
        // Rewind the stream
        $stream->rewind();

        // While the end of file hasn't been reached
        while (! $stream->eof()) {
            // Write the stream's contents to the handler
            fwrite($handle, $stream->read(4096));
        }

        // Close the file path
        fclose($handle);
    }
protected function writeStream ( string $ path ) : void { // Attempt to open the path specified $ handle = fopen ( $ path , 'wb+' ) ; // If the handler failed to open if ( false === $ handle ) { // Throw a runtime exception throw new RuntimeException ( 'Unable to write to designated path' ) ; } // Get the stream $ stream = $ this -> getStream ( ) ; // Rewind the stream $ stream -> rewind ( ) ; // While the end of file hasn't been reached while ( ! $ stream -> eof ( ) ) { // Write the stream's contents to the handler fwrite ( $ handle , $ stream -> read ( 4096 ) ) ; } // Close the file path fclose ( $ handle ) ; }
Write the stream to a path.

@param string $path The path to write the stream to

@throws \RuntimeException
@throws \Valkyrja\HttpMessage\Exceptions\InvalidStream

@return void
Write the stream to a path .