コード例 #1
0
ファイル: InflateStream.php プロジェクト: kirill-konshin/psr7
 public function __construct(StreamInterface $stream)
 {
     // Skip the first 10 bytes
     $stream = new LimitStream($stream, -1, 10);
     $resource = StreamWrapper::getResource($stream);
     stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
     parent::__construct(new Stream($resource));
 }
コード例 #2
0
 /**
  * @param array  $elements Array of associative arrays, each containing a
  *                         required "name" key mapping to the form field,
  *                         name, a required "contents" key mapping to a
  *                         StreamInterface/resource/string, an optional
  *                         "headers" associative array of custom headers,
  *                         and an optional "filename" key mapping to a
  *                         string to send as the filename in the part.
  * @param string $boundary You can optionally provide a specific boundary
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(array $elements = array(), $boundary = null)
 {
     $this->boundary = $boundary ?: uniqid();
     parent::__construct($this->createStream($elements));
 }
コード例 #3
0
ファイル: LimitStream.php プロジェクト: kirill-konshin/psr7
 /**
  * @param StreamInterface $stream Stream to wrap
  * @param int             $limit  Total number of bytes to allow to be read
  *                                from the stream. Pass -1 for no limit.
  * @param int|null        $offset Position to seek to before reading (only
  *                                works on seekable streams).
  */
 public function __construct(StreamInterface $stream, $limit = -1, $offset = 0)
 {
     parent::__construct($stream);
     $this->setLimit($limit);
     $this->setOffset($offset);
 }
コード例 #4
0
ファイル: CachingStream.php プロジェクト: kirill-konshin/psr7
 /**
  * We will treat the buffer object as the body of the stream
  *
  * @param StreamInterface $stream Stream to cache
  * @param StreamInterface $target Optionally specify where data is cached
  */
 public function __construct(StreamInterface $stream, StreamInterface $target = null)
 {
     $this->remoteStream = $stream;
     parent::__construct($target ?: new Stream(fopen('php://temp', 'r+')));
 }
コード例 #5
0
 /**
  * @param StreamInterface $stream    Underlying stream to decorate.
  * @param int             $maxLength Maximum size before dropping data.
  */
 public function __construct(StreamInterface $stream, $maxLength)
 {
     parent::__construct($stream);
     $this->maxLength = $maxLength;
 }
コード例 #6
0
 /**
  * @param string $filename File to lazily open
  * @param string $mode     fopen mode to use when opening the stream
  */
 public function __construct($filename, $mode)
 {
     $this->filename = $filename;
     $this->mode = $mode;
     parent::__construct();
 }