You are here

public function Stream::__toString in Zircon Profile 8

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

Reads all data from the stream into a string, from the beginning to end.

This method MUST attempt to seek to the beginning of the stream before reading data and read the stream until the end is reached.

Warning: This could attempt to load a large amount of data into memory.

This method MUST NOT raise an exception in order to conform with PHP's string casting operations.

Return value

string

Overrides StreamInterface::__toString

See also

http://php.net/manual/en/language.oop5.magic.php#object.tostring

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

File

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

Class

Stream
Implementation of PSR HTTP streams

Namespace

Zend\Diactoros

Code

public function __toString() {
  if (!$this
    ->isReadable()) {
    return '';
  }
  try {
    $this
      ->rewind();
    return $this
      ->getContents();
  } catch (RuntimeException $e) {
    return '';
  }
}