Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LazyOpenStream.php

class LazyOpenStream

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

Hierarchy

  • class \GuzzleHttp\Psr7\LazyOpenStream implements \Psr\Http\Message\StreamInterface uses \GuzzleHttp\Psr7\StreamDecoratorTrait

Expanded class hierarchy of LazyOpenStream

1 file declares its use of LazyOpenStream
CurlFactory.php in vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php

File

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

Namespace

GuzzleHttp\Psr7
View source
final class LazyOpenStream implements StreamInterface {
    use StreamDecoratorTrait;
    
    /** @var string */
    private $filename;
    
    /** @var string */
    private $mode;
    
    /**
     * @var StreamInterface
     */
    private $stream;
    
    /**
     * @param string $filename File to lazily open
     * @param string $mode     fopen mode to use when opening the stream
     */
    public function __construct(string $filename, string $mode) {
        $this->filename = $filename;
        $this->mode = $mode;
        // unsetting the property forces the first access to go through
        // __get().
        unset($this->stream);
    }
    
    /**
     * Creates the underlying stream lazily when required.
     */
    protected function createStream() : StreamInterface {
        return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
LazyOpenStream::$filename private property @var string
LazyOpenStream::$mode private property @var string
LazyOpenStream::$stream private property
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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal