You are here

public function Stream::getSize in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::getSize()
  2. 8 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::getSize()
  3. 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream::getSize()
Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::getSize()

Get the size of the stream if known.

Return value

int|null Returns the size in bytes if known, or null if unknown.

Overrides StreamInterface::getSize

File

vendor/guzzlehttp/psr7/src/Stream.php, line 135

Class

Stream
PHP stream implementation.

Namespace

GuzzleHttp\Psr7

Code

public function getSize() {
  if ($this->size !== null) {
    return $this->size;
  }
  if (!isset($this->stream)) {
    return null;
  }

  // Clear the stat cache if the stream has a URI
  if ($this->uri) {
    clearstatcache(true, $this->uri);
  }
  $stats = fstat($this->stream);
  if (isset($stats['size'])) {
    $this->size = $stats['size'];
    return $this->size;
  }
  return null;
}