RelativeStream.php in Zircon Profile 8.0
File
vendor/zendframework/zend-diactoros/src/RelativeStream.php
View source
<?php
namespace Zend\Diactoros;
use Psr\Http\Message\StreamInterface;
final class RelativeStream implements StreamInterface {
private $decoratedStream;
private $offset;
public function __construct(StreamInterface $decoratedStream, $offset) {
$this->decoratedStream = $decoratedStream;
$this->offset = (int) $offset;
}
public function __toString() {
$this
->seek(0);
return $this
->getContents();
}
public function close() {
$this->decoratedStream
->close();
}
public function detach() {
return $this->decoratedStream
->detach();
}
public function getSize() {
return $this->decoratedStream
->getSize() - $this->offset;
}
public function tell() {
return $this->decoratedStream
->tell() - $this->offset;
}
public function eof() {
return $this->decoratedStream
->eof();
}
public function isSeekable() {
return $this->decoratedStream
->isSeekable();
}
public function seek($offset, $whence = SEEK_SET) {
if ($whence == SEEK_SET) {
return $this->decoratedStream
->seek($offset + $this->offset, $whence);
}
return $this->decoratedStream
->seek($offset, $whence);
}
public function rewind() {
return $this
->seek(0);
}
public function isWritable() {
return $this->decoratedStream
->isWritable();
}
public function write($string) {
return $this->decoratedStream
->write($string);
}
public function isReadable() {
return $this->decoratedStream
->isReadable();
}
public function read($length) {
return $this->decoratedStream
->read($length);
}
public function getContents() {
return $this->decoratedStream
->getContents();
}
public function getMetadata($key = null) {
return $this->decoratedStream
->getMetadata($key);
}
}