Get the size of the stream if able
int|bool
Overrides StreamInterface::getSize
public function getSize() {
if ($this->size !== null) {
return $this->size;
}
// If the stream is a file based stream and local, then check the filesize
if ($this
->isLocal() && $this
->getWrapper() == 'plainfile' && $this
->getUri() && file_exists($this
->getUri())) {
return filesize($this
->getUri());
}
// Only get the size based on the content if the the stream is readable and seekable
if (!$this->cache[self::IS_READABLE] || !$this->cache[self::SEEKABLE]) {
return false;
}
else {
$pos = $this
->ftell();
$this->size = strlen((string) $this);
$this
->seek($pos);
return $this->size;
}
}