← All changes
|
vendor_prefixed/guzzlehttp/psr7/src/LazyOpenStream.php
+0
-41
28.3
→
trunk
View file →
| @@ -1,41 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -declare (strict_types=1); | |
| 4 | -namespace YoastSEO_Vendor\GuzzleHttp\Psr7; | |
| 5 | - | |
| 6 | -use YoastSEO_Vendor\Psr\Http\Message\StreamInterface; | |
| 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 class LazyOpenStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface | |
| 12 | -{ | |
| 13 | - use StreamDecoratorTrait; | |
| 14 | - /** @var string */ | |
| 15 | - private $filename; | |
| 16 | - /** @var string */ | |
| 17 | - private $mode; | |
| 18 | - /** | |
| 19 | - * @var StreamInterface | |
| 20 | - */ | |
| 21 | - private $stream; | |
| 22 | - /** | |
| 23 | - * @param string $filename File to lazily open | |
| 24 | - * @param string $mode fopen mode to use when opening the stream | |
| 25 | - */ | |
| 26 | - public function __construct(string $filename, string $mode) | |
| 27 | - { | |
| 28 | - $this->filename = $filename; | |
| 29 | - $this->mode = $mode; | |
| 30 | - // unsetting the property forces the first access to go through | |
| 31 | - // __get(). | |
| 32 | - unset($this->stream); | |
| 33 | - } | |
| 34 | - /** | |
| 35 | - * Creates the underlying stream lazily when required. | |
| 36 | - */ | |
| 37 | - protected function createStream() : \YoastSEO_Vendor\Psr\Http\Message\StreamInterface | |
| 38 | - { | |
| 39 | - return \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::streamFor(\YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::tryFopen($this->filename, $this->mode)); | |
| 40 | - } | |
| 41 | -} | |