當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StreamInterface::isReadable方法代碼示例

本文整理匯總了PHP中Psr\Http\Message\StreamInterface::isReadable方法的典型用法代碼示例。如果您正苦於以下問題:PHP StreamInterface::isReadable方法的具體用法?PHP StreamInterface::isReadable怎麽用?PHP StreamInterface::isReadable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Http\Message\StreamInterface的用法示例。


在下文中一共展示了StreamInterface::isReadable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Decorate the given input stream.
  * 
  * @param StreamInterface $stream
  * 
  * @throws \InvalidArgumentException When the given stream is not readable.
  */
 public function __construct(StreamInterface $stream)
 {
     if (!$stream->isReadable()) {
         throw new \InvalidArgumentException(sprintf('Decorated stream must be readable, given %s', get_class($stream)));
     }
     $this->stream = $stream;
 }
開發者ID:koolkode,項目名稱:stream,代碼行數:14,代碼來源:AbstractInputStream.php

示例2: appendStream

 /**
  * Append another input stream.
  * 
  * @param StreamInterface $stream
  * 
  * @throws \InvalidArgumentException When the given stream is not readable.
  */
 public function appendStream(StreamInterface $stream)
 {
     if (!$stream->isReadable()) {
         throw new \InvalidArgumentException('Appended input stream must be readable');
     }
     $this->streams[] = $stream;
 }
開發者ID:koolkode,項目名稱:stream,代碼行數:14,代碼來源:AppendInputStream.php

示例3: __construct

 public function __construct($filename, StreamInterface $stream, $mediaType = NULL)
 {
     if (!$stream->isReadable()) {
         throw new \InvalidArgumentException(sprintf('Input stream of file "%s" must be readable'));
     }
     $this->fileName = new UnicodeString($filename);
     $this->stream = $stream;
     $this->mediaType = $mediaType === NULL ? Filesystem::guessMimeTypeFromFilename($this->fileName) : new MediaType($mediaType);
 }
開發者ID:koolkode,項目名稱:http,代碼行數:9,代碼來源:UploadedFile.php

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: getResource

 /**
  * Returns a resource representing the stream.
  *
  * @param StreamInterface $stream The stream to get a resource for
  *
  * @return resource
  * @throws \InvalidArgumentException if stream is not readable or writable
  */
 public static function getResource(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(['guzzle' => ['stream' => $stream]]));
 }
開發者ID:Rayac,項目名稱:search,代碼行數:20,代碼來源:StreamWrapper.php

示例9: 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

示例10: isReadable

 /**
  * {@inheritdoc}
  */
 public function isReadable()
 {
     return $this->stream->isReadable();
 }
開發者ID:narrowspark,項目名稱:framework,代碼行數:7,代碼來源:AbstractStreamDecorator.php

示例11: testDetaches

 public function testDetaches()
 {
     $this->b->detach();
     $this->assertFalse($this->b->isReadable());
 }
開發者ID:nystudio107,項目名稱:instantanalytics,代碼行數:5,代碼來源:StreamDecoratorTraitTest.php

示例12: isReadable

 /**
  * {@inheritdoc}
  */
 public function isReadable()
 {
     return $this->decoratedStream->isReadable();
 }
開發者ID:zendframework,項目名稱:zend-diactoros,代碼行數:7,代碼來源:RelativeStream.php

示例13: getResource

 /**
  * Create StreamInterface associated resource.
  *
  * @param StreamInterface $stream
  * @return resource
  * @throws WrapperException
  */
 public static function getResource(StreamInterface $stream)
 {
     $mode = null;
     if ($stream->isReadable()) {
         $mode = 'r';
     }
     if ($stream->isWritable()) {
         $mode = !empty($mode) ? 'r+' : 'w';
     }
     if (empty($mode)) {
         throw new WrapperException("Stream is not available in read or write modes.");
     }
     return fopen(self::getUri($stream), $mode);
 }
開發者ID:tuneyourserver,項目名稱:components,代碼行數:21,代碼來源:StreamWrapper.php

示例14: runMatches

 protected function runMatches(StreamInterface $stream)
 {
     return $stream->isReadable();
 }
開發者ID:oscarotero,項目名稱:psr7-unitesting,代碼行數:4,代碼來源:IsReadable.php

示例15: writeFileContents

 protected function writeFileContents($file, StreamInterface $stream)
 {
     if (!$stream->isReadable()) {
         throw new \InvalidArgumentException('Resource content stream must be readable');
     }
     $fp = Filesystem::openWriteStream($file, 'wb', 0755, LOCK_EX);
     try {
         while (!$stream->eof()) {
             fwrite($fp, $stream->read(4096));
         }
     } finally {
         @fclose($fp);
     }
 }
開發者ID:koolkode,項目名稱:webdav,代碼行數:14,代碼來源:FilesystemStorage.php


注:本文中的Psr\Http\Message\StreamInterface::isReadable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。