| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace GuzzleHttp\Psr7; |
| 6 |
|
| 7 |
use Psr\Http\Message\StreamInterface; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
final class LazyOpenStream implements StreamInterface |
| 14 |
{ |
| 15 |
use StreamDecoratorTrait; |
| 16 |
|
| 17 |
|
| 18 |
private $filename; |
| 19 |
|
| 20 |
|
| 21 |
private $mode; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
private $stream; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
public function __construct(string $filename, string $mode) |
| 33 |
{ |
| 34 |
$this->filename = $filename; |
| 35 |
$this->mode = $mode; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
unset($this->stream); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
protected function createStream(): StreamInterface |
| 46 |
{ |
| 47 |
return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode)); |
| 48 |
} |
| 49 |
} |