You are here

public function Stream::getContents in Zircon Profile 8

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

Returns the remaining contents in a string

Return value

string

Throws

\RuntimeException if unable to read or an error occurs while reading.

Overrides StreamInterface::getContents

1 call to Stream::getContents()
Stream::__toString in vendor/zendframework/zend-diactoros/src/Stream.php
Reads all data from the stream into a string, from the beginning to end.
1 method overrides Stream::getContents()
PhpInputStream::getContents in vendor/zendframework/zend-diactoros/src/PhpInputStream.php
Returns the remaining contents in a string

File

vendor/zendframework/zend-diactoros/src/Stream.php, line 262

Class

Stream
Implementation of PSR HTTP streams

Namespace

Zend\Diactoros

Code

public function getContents() {
  if (!$this
    ->isReadable()) {
    throw new RuntimeException('Stream is not readable');
  }
  $result = stream_get_contents($this->resource);
  if (false === $result) {
    throw new RuntimeException('Error reading from stream');
  }
  return $result;
}