public function Stream::__construct in Zircon Profile 8
Same name in this branch
- 8 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::__construct()
- 8 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::__construct()
- 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream::__construct()
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::__construct()
This constructor accepts an associative array of options.
- size: (int) If a read stream would otherwise have an indeterminate size, but the size is known due to foreknownledge, then you can provide that size, in bytes.
- metadata: (array) Any additional metadata to return when the metadata of the stream is accessed.
Parameters
resource $stream Stream resource to wrap.:
array $options Associative array of options.:
Throws
\InvalidArgumentException if the stream is not a stream resource
File
- vendor/
guzzlehttp/ psr7/ src/ Stream.php, line 51
Class
- Stream
- PHP stream implementation.
Namespace
GuzzleHttp\Psr7Code
public function __construct($stream, $options = []) {
if (!is_resource($stream)) {
throw new \InvalidArgumentException('Stream must be a resource');
}
if (isset($options['size'])) {
$this->size = $options['size'];
}
$this->customMetadata = isset($options['metadata']) ? $options['metadata'] : [];
$this->stream = $stream;
$meta = stream_get_meta_data($this->stream);
$this->seekable = $meta['seekable'];
$this->readable = isset(self::$readWriteHash['read'][$meta['mode']]);
$this->writable = isset(self::$readWriteHash['write'][$meta['mode']]);
$this->uri = $this
->getMetadata('uri');
}