[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/guzzlehttp/psr7/src/ -> LazyOpenStream.php (source)

   1  <?php
   2  
   3  namespace GuzzleHttp\Psr7;
   4  
   5  use Psr\Http\Message\StreamInterface;
   6  
   7  /**
   8   * Lazily reads or writes to a file that is opened only after an IO operation
   9   * take place on the stream.
  10   *
  11   * @final
  12   */
  13  class LazyOpenStream implements StreamInterface
  14  {
  15      use StreamDecoratorTrait;
  16  
  17      /** @var string File to open */
  18      private $filename;
  19  
  20      /** @var string */
  21      private $mode;
  22  
  23      /**
  24       * @param string $filename File to lazily open
  25       * @param string $mode     fopen mode to use when opening the stream
  26       */
  27      public function __construct($filename, $mode)
  28      {
  29          $this->filename = $filename;
  30          $this->mode = $mode;
  31      }
  32  
  33      /**
  34       * Creates the underlying stream lazily when required.
  35       *
  36       * @return StreamInterface
  37       */
  38      protected function createStream()
  39      {
  40          return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
  41      }
  42  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1