You are here

class LazyOpenStream in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/LazyOpenStream.php \GuzzleHttp\Psr7\LazyOpenStream

Lazily reads or writes to a file that is opened only after an IO operation take place on the stream.

Hierarchy

Expanded class hierarchy of LazyOpenStream

2 files declare their use of LazyOpenStream
CurlFactory.php in vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
LazyOpenStreamTest.php in vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php

File

vendor/guzzlehttp/psr7/src/LazyOpenStream.php, line 10

Namespace

GuzzleHttp\Psr7
View source
class LazyOpenStream implements StreamInterface {
  use StreamDecoratorTrait;

  /** @var string File to open */
  private $filename;

  /** @var string $mode */
  private $mode;

  /**
   * @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;
  }

  /**
   * Creates the underlying stream lazily when required.
   *
   * @return StreamInterface
   */
  protected function createStream() {
    return stream_for(try_fopen($this->filename, $this->mode));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LazyOpenStream::$filename private property @var string File to open
LazyOpenStream::$mode private property @var string $mode
LazyOpenStream::createStream protected function Creates the underlying stream lazily when required. Overrides StreamDecoratorTrait::createStream
LazyOpenStream::__construct public function Overrides StreamDecoratorTrait::__construct
StreamDecoratorTrait::close public function 1
StreamDecoratorTrait::detach public function
StreamDecoratorTrait::eof public function 2
StreamDecoratorTrait::getContents public function
StreamDecoratorTrait::getMetadata public function
StreamDecoratorTrait::getSize public function 2
StreamDecoratorTrait::isReadable public function
StreamDecoratorTrait::isSeekable public function 1
StreamDecoratorTrait::isWritable public function 1
StreamDecoratorTrait::read public function 2
StreamDecoratorTrait::rewind public function 1
StreamDecoratorTrait::seek public function 3
StreamDecoratorTrait::tell public function 1
StreamDecoratorTrait::write public function 2
StreamDecoratorTrait::__call public function Allow decorators to implement custom methods
StreamDecoratorTrait::__get public function Magic method used to create a new stream if streams are not added in the constructor of a decorator (e.g., LazyOpenStream).
StreamDecoratorTrait::__toString public function