37 throw new \InvalidArgumentException(
'The stream must be readable, ' 38 .
'writable, or both.');
41 return fopen(
'guzzle://stream',
$mode, null, stream_context_create([
42 'guzzle' => [
'stream' => $stream]
49 public static function register()
51 if (!in_array(
'guzzle', stream_get_wrappers())) {
52 stream_wrapper_register(
'guzzle', __CLASS__);
58 $options = stream_context_get_options($this->context);
60 if (!isset(
$options[
'guzzle'][
'stream'])) {
65 $this->stream =
$options[
'guzzle'][
'stream'];
72 return $this->stream->read($count);
77 return (
int) $this->stream->write(
$data);
82 return $this->stream->tell();
87 return $this->stream->eof();
92 $this->stream->seek($offset, $whence);
113 'size' => $this->stream->getSize() ?: 0,
Converts Guzzle streams into PHP stream resources.
isWritable()
Returns whether or not the stream is writable.
static getResource(StreamInterface $stream)
Returns a resource representing the stream.
stream_seek($offset, $whence)
stream_open($path, $mode, $options, &$opened_path)
isReadable()
Returns whether or not the stream is readable.