You are here

public static function StreamWrapper::getResource in Lockr 7.3

Returns a resource representing the stream.

Parameters

StreamInterface $stream The stream to get a resource for:

Return value

resource

Throws

\InvalidArgumentException if stream is not readable or writable

1 call to StreamWrapper::getResource()
InflateStream::__construct in vendor/guzzlehttp/psr7/src/InflateStream.php

File

vendor/guzzlehttp/psr7/src/StreamWrapper.php, line 28

Class

StreamWrapper
Converts Guzzle streams into PHP stream resources.

Namespace

GuzzleHttp\Psr7

Code

public static function getResource(StreamInterface $stream) {
  self::register();
  if ($stream
    ->isReadable()) {
    $mode = $stream
      ->isWritable() ? 'r+' : 'r';
  }
  elseif ($stream
    ->isWritable()) {
    $mode = 'w';
  }
  else {
    throw new \InvalidArgumentException('The stream must be readable, ' . 'writable, or both.');
  }
  return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
}