# media-cloud-sync/1.2.12/includes/sdk/s3/GuzzleHttp/Psr7/LazyOpenStream.php

Media Cloud Sync, version 1.2.12. 38 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.2.12/code/includes/sdk/s3/GuzzleHttp/Psr7/LazyOpenStream.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.2.12/raw/includes/sdk/s3/GuzzleHttp/Psr7/LazyOpenStream.php
- Modified: 2024-10-27T10:40:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/media-cloud-sync/1.2.12/code/includes/sdk/s3/GuzzleHttp/Psr7/LazyOpenStream.php#L10-L20`.

```php
<?php

namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7;

use Dudlewebs\WPMCS\s3\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 File to open */
    private $filename;
    /** @var string */
    private $mode;
    /**
     * @param string $filename File to lazily open
     * @param string $mode     fopen mode to use when opening the stream
     */
    public function __construct($filename, $mode)
    {
        $this->filename = $filename;
        $this->mode = $mode;
    }
    /**
     * Creates the underlying stream lazily when required.
     *
     * @return StreamInterface
     */
    protected function createStream()
    {
        return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
    }
}

```
