Chris@0: decoratedStream = $decoratedStream; Chris@0: $this->offset = (int)$offset; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function __toString() Chris@0: { Chris@0: if ($this->isSeekable()) { Chris@0: $this->seek(0); Chris@0: } Chris@0: return $this->getContents(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function close() Chris@0: { Chris@0: $this->decoratedStream->close(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function detach() Chris@0: { Chris@0: return $this->decoratedStream->detach(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getSize() Chris@0: { Chris@0: return $this->decoratedStream->getSize() - $this->offset; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function tell() Chris@0: { Chris@0: return $this->decoratedStream->tell() - $this->offset; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function eof() Chris@0: { Chris@0: return $this->decoratedStream->eof(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isSeekable() Chris@0: { Chris@0: return $this->decoratedStream->isSeekable(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function seek($offset, $whence = SEEK_SET) Chris@0: { Chris@0: if ($whence == SEEK_SET) { Chris@0: return $this->decoratedStream->seek($offset + $this->offset, $whence); Chris@0: } Chris@0: return $this->decoratedStream->seek($offset, $whence); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function rewind() Chris@0: { Chris@0: return $this->seek(0); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isWritable() Chris@0: { Chris@0: return $this->decoratedStream->isWritable(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function write($string) Chris@0: { Chris@0: if ($this->tell() < 0) { Chris@0: throw new RuntimeException('Invalid pointer position'); Chris@0: } Chris@0: return $this->decoratedStream->write($string); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isReadable() Chris@0: { Chris@0: return $this->decoratedStream->isReadable(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function read($length) Chris@0: { Chris@0: if ($this->tell() < 0) { Chris@0: throw new RuntimeException('Invalid pointer position'); Chris@0: } Chris@0: return $this->decoratedStream->read($length); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getContents() Chris@0: { Chris@0: if ($this->tell() < 0) { Chris@0: throw new RuntimeException('Invalid pointer position'); Chris@0: } Chris@0: return $this->decoratedStream->getContents(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getMetadata($key = null) Chris@0: { Chris@0: return $this->decoratedStream->getMetadata($key); Chris@0: } Chris@0: }