<?php declare(strict_types=1); namespace GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; /** * Lazily reads or writes to a file that is opened only after an IO operation * take place on the stream. */ 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)); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Exception | Folder | 0755 |
|
|
AppendStream.php | File | 5.84 KB | 0644 |
|
BufferStream.php | File | 3.17 KB | 0644 |
|
CachingStream.php | File | 4.48 KB | 0644 |
|
DroppingStream.php | File | 1.17 KB | 0644 |
|
FnStream.php | File | 4.4 KB | 0644 |
|
Header.php | File | 3.84 KB | 0644 |
|
HttpFactory.php | File | 3.02 KB | 0644 |
|
InflateStream.php | File | 1.36 KB | 0644 |
|
LazyOpenStream.php | File | 1.06 KB | 0644 |
|
LimitStream.php | File | 4.2 KB | 0644 |
|
Message.php | File | 8.13 KB | 0644 |
|
MessageTrait.php | File | 7.57 KB | 0644 |
|
MimeType.php | File | 52.9 KB | 0644 |
|
MultipartStream.php | File | 4.92 KB | 0644 |
|
NoSeekStream.php | File | 524 B | 0644 |
|
PumpStream.php | File | 4.5 KB | 0644 |
|
Query.php | File | 3.57 KB | 0644 |
|
Request.php | File | 3.81 KB | 0644 |
|
Response.php | File | 4.79 KB | 0644 |
|
Rfc7230.php | File | 665 B | 0644 |
|
ServerRequest.php | File | 9.4 KB | 0644 |
|
Stream.php | File | 7.23 KB | 0644 |
|
StreamDecoratorTrait.php | File | 3.28 KB | 0644 |
|
StreamWrapper.php | File | 4.01 KB | 0644 |
|
UploadedFile.php | File | 4.75 KB | 0644 |
|
Uri.php | File | 21.36 KB | 0644 |
|
UriComparator.php | File | 1.12 KB | 0644 |
|
UriNormalizer.php | File | 8.22 KB | 0644 |
|
UriResolver.php | File | 8.36 KB | 0644 |
|
Utils.php | File | 15.2 KB | 0644 |
|