當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。