/** * Reads the content of this stream and write it to another stream. * * @param instance $stream The destination stream to write to * @return integer The number of copied bytes */ public function pipe($stream) { $offset = $stream->tell(); $result = stream_copy_to_stream($this->resource(), $stream->resource()); if ($stream->isSeekable()) { $stream->seek($offset); } return $result; }