当前位置: 首页>>代码示例>>PHP>>正文


PHP StreamInterface::isSeekable方法代码示例

本文整理汇总了PHP中Psr\Http\Message\StreamInterface::isSeekable方法的典型用法代码示例。如果您正苦于以下问题:PHP StreamInterface::isSeekable方法的具体用法?PHP StreamInterface::isSeekable怎么用?PHP StreamInterface::isSeekable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Http\Message\StreamInterface的用法示例。


在下文中一共展示了StreamInterface::isSeekable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copy

 /**
  * Copy stream to another stream.
  *
  * @param   StreamInterface  $src   Source stream.
  * @param   StreamInterface  $dest  Target stream.
  *
  * @return  void
  */
 public static function copy(StreamInterface $src, StreamInterface $dest)
 {
     if ($src->isSeekable()) {
         $src->rewind();
     }
     while (!$src->eof()) {
         $dest->write($src->read(4096));
     }
 }
开发者ID:kaiwa,项目名称:http,代码行数:17,代码来源:StreamHelper.php

示例2: add

 /**
  * Append stream to stack.
  *
  * @param  StreamInterface $stream
  * @return self
  */
 public function add(StreamInterface $stream)
 {
     if (!$stream->isReadable()) {
         throw new \InvalidArgumentException('Each stream must be readable');
     }
     $this->seekable = $stream->isSeekable() && $this->seekable;
     $this->streams[] = $stream;
     return $this;
 }
开发者ID:ptcong,项目名称:easyrequest,代码行数:15,代码来源:AppendStream.php

示例3: fromStream

 /**
  * Parse a response from a stream.
  *
  * @param StreamInterface $stream
  * @return ResponseInterface
  * @throws InvalidArgumentException when the stream is not readable.
  * @throws UnexpectedValueException when errors occur parsing the message.
  */
 public static function fromStream(StreamInterface $stream)
 {
     if (!$stream->isReadable() || !$stream->isSeekable()) {
         throw new InvalidArgumentException('Message stream must be both readable and seekable');
     }
     $stream->rewind();
     list($version, $status, $reasonPhrase) = self::getStatusLine($stream);
     list($headers, $body) = self::splitStream($stream);
     return (new Response($body, $status, $headers))->withProtocolVersion($version)->withStatus((int) $status, $reasonPhrase);
 }
开发者ID:DenLilleMand,项目名称:christianssite,代码行数:18,代码来源:Serializer.php

示例4: addStream

 /**
  * Add a stream to the AppendStream
  *
  * @param StreamInterface $stream Stream to append. Must be readable.
  *
  * @throws \InvalidArgumentException if the stream is not readable
  */
 public function addStream(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;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:18,代码来源:AppendStream.php

示例5: fromStream

 /**
  * Deserialize a request stream to a request instance.
  *
  * @param StreamInterface $stream
  * @return Request
  * @throws UnexpectedValueException when errors occur parsing the message.
  */
 public static function fromStream(StreamInterface $stream)
 {
     if (!$stream->isReadable() || !$stream->isSeekable()) {
         throw new InvalidArgumentException('Message stream must be both readable and seekable');
     }
     $stream->rewind();
     list($method, $requestTarget, $version) = self::getRequestLine($stream);
     $uri = self::createUriFromRequestTarget($requestTarget);
     list($headers, $body) = self::splitStream($stream);
     return (new Request($uri, $method, $body, $headers))->withProtocolVersion($version)->withRequestTarget($requestTarget);
 }
开发者ID:zendframework,项目名称:zend-diactoros,代码行数:18,代码来源:Serializer.php

示例6: toString

 /**
  * Converts an stream into an string and returns the result. The position of
  * the pointer will not change if the stream is seekable. Note this copies
  * the complete content of the stream into the memory
  *
  * @param \Psr\Http\Message\StreamInterface $stream
  * @return string
  */
 public static function toString(StreamInterface $stream)
 {
     if (!$stream->isReadable()) {
         return '';
     }
     if ($stream->isSeekable()) {
         $pos = $stream->tell();
         if ($pos > 0) {
             $stream->seek(0);
         }
         $content = $stream->getContents();
         $stream->seek($pos);
     } else {
         $content = $stream->getContents();
     }
     return $content;
 }
开发者ID:seytar,项目名称:psx,代码行数:25,代码来源:Util.php

示例7: isSeekable

 /**
  * {@inheritdoc}
  */
 public function isSeekable()
 {
     return $this->stream->isSeekable();
 }
开发者ID:narrowspark,项目名称:framework,代码行数:7,代码来源:AbstractStreamDecorator.php

示例8: isSeekable

 /**
  * {@inheritdoc}
  */
 public function isSeekable()
 {
     return $this->decoratedStream->isSeekable();
 }
开发者ID:zendframework,项目名称:zend-diactoros,代码行数:7,代码来源:RelativeStream.php

示例9: outputBody

 private function outputBody(StreamInterface $body)
 {
     if ($this->chunkSize > 0) {
         if ($body->isSeekable()) {
             $body->rewind();
         }
         while (!$body->eof()) {
             print $body->read($this->chunkSize);
         }
     } else {
         print (string) $body;
     }
 }
开发者ID:pjdietz,项目名称:wellrested,代码行数:13,代码来源:Transmitter.php

示例10: runMatches

 protected function runMatches(StreamInterface $stream)
 {
     return $stream->isSeekable();
 }
开发者ID:oscarotero,项目名称:psr7-unitesting,代码行数:4,代码来源:IsSeekable.php

示例11: parseCsv

 /**
  * Parses csv.
  * 
  * @param StreamInterface $body
  * 
  * @return array
  */
 protected function parseCsv(StreamInterface $body)
 {
     if ($body->isSeekable()) {
         $body->rewind();
     }
     $stream = $body->detach();
     $data = [];
     while (($row = fgetcsv($stream)) !== false) {
         $data[] = $row;
     }
     fclose($stream);
     return $data;
 }
开发者ID:jordiwes,项目名称:psr7-middlewares,代码行数:20,代码来源:Payload.php

示例12: testCheckMethods

 public function testCheckMethods()
 {
     $this->assertEquals($this->a->isReadable(), $this->b->isReadable());
     $this->assertEquals($this->a->isWritable(), $this->b->isWritable());
     $this->assertEquals($this->a->isSeekable(), $this->b->isSeekable());
 }
开发者ID:nystudio107,项目名称:instantanalytics,代码行数:6,代码来源:StreamDecoratorTraitTest.php


注:本文中的Psr\Http\Message\StreamInterface::isSeekable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。