<?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.81 KB | 0644 |
|
| BufferStream.php | File | 3.14 KB | 0644 |
|
| CachingStream.php | File | 4.49 KB | 0644 |
|
| DroppingStream.php | File | 1.17 KB | 0644 |
|
| FnStream.php | File | 4.21 KB | 0644 |
|
| Header.php | File | 3.85 KB | 0644 |
|
| HttpFactory.php | File | 3 KB | 0644 |
|
| InflateStream.php | File | 1.38 KB | 0644 |
|
| LazyOpenStream.php | File | 1.06 KB | 0644 |
|
| LimitStream.php | File | 4.18 KB | 0644 |
|
| Message.php | File | 8.14 KB | 0644 |
|
| MessageTrait.php | File | 7.61 KB | 0644 |
|
| MimeType.php | File | 55.82 KB | 0644 |
|
| MultipartStream.php | File | 6.85 KB | 0644 |
|
| NoSeekStream.php | File | 524 B | 0644 |
|
| PumpStream.php | File | 4.49 KB | 0644 |
|
| Query.php | File | 3.95 KB | 0644 |
|
| Request.php | File | 3.81 KB | 0644 |
|
| Response.php | File | 4.79 KB | 0644 |
|
| Rfc7230.php | File | 661 B | 0644 |
|
| ServerRequest.php | File | 9.33 KB | 0644 |
|
| Stream.php | File | 7.21 KB | 0644 |
|
| StreamDecoratorTrait.php | File | 3.24 KB | 0644 |
|
| StreamWrapper.php | File | 4.53 KB | 0644 |
|
| UploadedFile.php | File | 4.98 KB | 0644 |
|
| Uri.php | File | 21.5 KB | 0644 |
|
| UriComparator.php | File | 1.12 KB | 0644 |
|
| UriNormalizer.php | File | 8.26 KB | 0644 |
|
| UriResolver.php | File | 8.38 KB | 0644 |
|
| Utils.php | File | 15.57 KB | 0644 |
|