Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Stream.php

function 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 foreknowledge, 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{size?: int, metadata?: array} $options Associative array of options.:

Throws

\InvalidArgumentException if the stream is not a stream resource

File

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

Class

Stream
PHP stream implementation.

Namespace

GuzzleHttp\Psr7

Code

public function __construct($stream, array $options = []) {
    if (!is_resource($stream)) {
        throw new \InvalidArgumentException('Stream must be a resource');
    }
    if (isset($options['size'])) {
        $this->size = $options['size'];
    }
    $this->customMetadata = $options['metadata'] ?? [];
    $this->stream = $stream;
    $meta = stream_get_meta_data($this->stream);
    $this->seekable = $meta['seekable'];
    $this->readable = (bool) preg_match(self::READABLE_MODES, $meta['mode']);
    $this->writable = (bool) preg_match(self::WRITABLE_MODES, $meta['mode']);
    $this->uri = $this->getMetadata('uri');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal