/** * Get data. * * @throws RuntimeException * * @return string */ public function getData() { $offset = $this->stream->tell(); if (!is_int($offset)) { throw new RuntimeException('Unable to get profile data'); } $this->stream->seek(0); $data = $this->stream->getContents(); $this->stream->seek($offset); return $data; }
public function tell() { return $this->body ? $this->body->tell() : 0; }
/** * Calculate a hash of a Stream * * @param StreamInterface $stream Stream to calculate the hash for * @param string $algo Hash algorithm (e.g. md5, crc32, etc) * @param bool $rawOutput Whether or not to use raw output * * @return string Returns the hash of the stream * @throws SeekException */ public static function hash(StreamInterface $stream, $algo, $rawOutput = false) { $pos = $stream->tell(); if ($pos > 0 && !$stream->seek(0)) { throw new SeekException($stream); } $ctx = hash_init($algo); while (!$stream->eof()) { hash_update($ctx, $stream->read(1048576)); } $out = hash_final($ctx, (bool) $rawOutput); $stream->seek($pos); return $out; }
public function tell() { return $this->stream->tell(); }
/** * {@inheritdoc} */ protected function doTell() { return $this->stream->tell(); }