当前位置: 首页>>代码示例>>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;未经允许,请勿转载。