PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.20
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.20
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
woocommerce-pos / vendor_prefixed / guzzlehttp / psr7 / src / LazyOpenStream.php

LazyOpenStream.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.20, at vendor_prefixed/guzzlehttp/psr7/src/LazyOpenStream.php

43 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\GuzzleHttp\Psr7;
5
6 use WCPOS\Vendor\Psr\Http\Message\StreamInterface;
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 class LazyOpenStream implements StreamInterface
12 {
13 use StreamDecoratorTrait;
14 use NonSerializableStreamTrait;
15 private string $filename;
16 private string $mode;
17 private StreamInterface $stream;
18 /**
19 * @param string $filename File to lazily open
20 * @param string $mode fopen mode to use when opening the stream
21 */
22 public function __construct(string $filename, string $mode)
23 {
24 $this->filename = $filename;
25 $this->mode = $mode;
26 // unsetting the property forces the first access to go through
27 // __get().
28 unset($this->stream);
29 }
30 public function __unserialize(array $data) : void
31 {
32 $this->stream = new BufferStream();
33 throw new \LogicException(static::class . ' should never be unserialized');
34 }
35 /**
36 * Creates the underlying stream lazily when required.
37 */
38 protected function createStream() : StreamInterface
39 {
40 return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
41 }
42 }
43