public static function copy($stream, $close = true)
    {
        $cloned = fopen('php://temp', 'w+b');
        $pos = ftell($stream);

        static::tryRewind($stream);
        stream_copy_to_stream($stream, $cloned);

        if ($close) {
            fclose($stream);
        } else {
            static::trySeek($stream, $pos);
        }

        fseek($cloned, $pos);

        return $cloned;
    }
public static function copy($stream, $close = true)
    {
        $cloned = fopen('php://temp', 'w+b');
        $pos = ftell($stream);

        static::tryRewind($stream);
        stream_copy_to_stream($stream, $cloned);

        if ($close) {
            fclose($stream);
        } else {
            static::trySeek($stream, $pos);
        }

        fseek($cloned, $pos);

        return $cloned;
    }
public static function copy ( $ stream , $ close = true ) { $ cloned = fopen ( 'php://temp' , 'w+b' ) ; $ pos = ftell ( $ stream ) ; static :: tryRewind ( $ stream ) ; stream_copy_to_stream ( $ stream , $ cloned ) ; if ( $ close ) { fclose ( $ stream ) ; } else { static :: trySeek ( $ stream , $ pos ) ; } fseek ( $ cloned , $ pos ) ; return $ cloned ; }
Copies a stream.

@param resource $stream The stream to copy.
@param bool     $close  Whether to close the input stream.

@return resource The copied stream.
Copies a stream .