Beispiel #1
0
 /**
  * Add a stream to the AppendStream
  *
  * @param puzzle_stream_StreamInterface $stream Stream to append. Must be readable.
  *
  * @throws InvalidArgumentException if the stream is not readable
  */
 public function addStream(puzzle_stream_StreamInterface $stream)
 {
     if (!$stream->isReadable()) {
         throw new InvalidArgumentException('Each stream must be readable');
     }
     // The stream is only seekable if all streams are seekable
     if (!$stream->isSeekable()) {
         $this->seekable = false;
     }
     $this->streams[] = $stream;
 }
 /**
  * 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 isReadable()
 {
     return $this->_delegate->isReadable();
 }