📂 File Browser

AgentAI/vendor/guzzlehttp/psr7/src
🌙 Dark Mode
🎯 Quick Launch:

📁 Directories

📁 Exception/ 🔓 Open

📄 Files

🐘 AppendStream.php
▶ Open 📄 View Source
🐘 BufferStream.php
▶ Open 📄 View Source
🐘 CachingStream.php
▶ Open 📄 View Source
🐘 DroppingStream.php
▶ Open 📄 View Source
🐘 FnStream.php
▶ Open 📄 View Source
🐘 Header.php
▶ Open 📄 View Source
🐘 HttpFactory.php
▶ Open 📄 View Source
🐘 InflateStream.php
▶ Open 📄 View Source
🐘 LazyOpenStream.php
▶ Open 📄 View Source
🐘 LimitStream.php
▶ Open 📄 View Source
🐘 Message.php
▶ Open 📄 View Source
🐘 MessageTrait.php
▶ Open 📄 View Source
🐘 MimeType.php
▶ Open 📄 View Source
🐘 MultipartStream.php
▶ Open 📄 View Source
🐘 NoSeekStream.php
▶ Open 📄 View Source
🐘 PumpStream.php
▶ Open 📄 View Source
🐘 Query.php
▶ Open 📄 View Source
🐘 Request.php
▶ Open 📄 View Source
🐘 Response.php
▶ Open 📄 View Source
🐘 Rfc7230.php
▶ Open 📄 View Source
🐘 ServerRequest.php
▶ Open 📄 View Source
🐘 Stream.php
▶ Open 📄 View Source
🐘 StreamDecoratorTrait.php
▶ Open 📄 View Source
🐘 StreamWrapper.php
▶ Open 📄 View Source
🐘 UploadedFile.php
▶ Open 📄 View Source
🐘 Uri.php
▶ Open 📄 View Source
🐘 UriComparator.php
▶ Open 📄 View Source
🐘 UriNormalizer.php
▶ Open 📄 View Source
🐘 UriResolver.php
▶ Open 📄 View Source
🐘 Utils.php
▶ Open 📄 View Source

📄 Source: LazyOpenStream.php

<?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));
    }
}
← Back