PluginProbe
Depicter — Popup & Slider Builder / 1.3.2
Depicter — Popup & Slider Builder v1.3.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / modules / GuzzleHttp / Psr7 / LazyOpenStream.php

LazyOpenStream.php in Depicter — Popup & Slider Builder 1.3.2, at modules/GuzzleHttp/Psr7/LazyOpenStream.php

43 lines 918 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Depicter\GuzzleHttp\Psr7;
4
5 use Depicter\Psr\Http\Message\StreamInterface;
6
7 /**
8 * Lazily reads or writes to a file that is opened only after an IO operation
9 * take place on the stream.
10 *
11 * @final
12 */
13 class LazyOpenStream implements StreamInterface
14 {
15 use StreamDecoratorTrait;
16
17 /** @var string File to open */
18 private $filename;
19
20 /** @var string */
21 private $mode;
22
23 /**
24 * @param string $filename File to lazily open
25 * @param string $mode fopen mode to use when opening the stream
26 */
27 public function __construct($filename, $mode)
28 {
29 $this->filename = $filename;
30 $this->mode = $mode;
31 }
32
33 /**
34 * Creates the underlying stream lazily when required.
35 *
36 * @return StreamInterface
37 */
38 protected function createStream()
39 {
40 return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
41 }
42 }
43