/** * Returns a resource representing the stream. * * @param puzzle_stream_StreamInterface $stream The stream to get a resource for * * @return resource * @throws InvalidArgumentException if stream is not readable or writable */ public static function getResource(puzzle_stream_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, stream_context_create(array('guzzle' => array('stream' => $stream)))); }
/** * {@inheritdoc} */ public function isWritable() { return $this->_delegate->isWritable(); }