PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / guzzlehttp / psr7 / src / StreamWrapper.php
ameliabooking / vendor / guzzlehttp / psr7 / src Last commit date
AppendStream.php 3 years ago BufferStream.php 3 years ago CachingStream.php 3 years ago DroppingStream.php 3 years ago FnStream.php 3 years ago Header.php 5 years ago InflateStream.php 3 years ago LazyOpenStream.php 3 years ago LimitStream.php 3 years ago Message.php 3 years ago MessageTrait.php 2 years ago MimeType.php 5 years ago MultipartStream.php 3 years ago NoSeekStream.php 3 years ago PumpStream.php 3 years ago Query.php 4 years ago Request.php 3 years ago Response.php 3 years ago Rfc7230.php 4 years ago ServerRequest.php 3 years ago Stream.php 3 years ago StreamDecoratorTrait.php 3 years ago StreamWrapper.php 3 years ago UploadedFile.php 3 years ago Uri.php 3 years ago UriComparator.php 2 years ago UriNormalizer.php 3 years ago UriResolver.php 3 years ago Utils.php 3 years ago functions.php 3 years ago functions_include.php 5 years ago
StreamWrapper.php
166 lines
1 <?php
2
3 namespace AmeliaGuzzleHttp\Psr7;
4
5 use AmeliaPsr\Http\Message\StreamInterface;
6
7 /**
8 * Converts Guzzle streams into PHP stream resources.
9 *
10 * @final
11 */
12 class StreamWrapper
13 {
14 /** @var resource */
15 public $context;
16
17 /** @var StreamInterface */
18 private $stream;
19
20 /** @var string r, r+, or w */
21 private $mode;
22
23 /**
24 * Returns a resource representing the stream.
25 *
26 * @param StreamInterface $stream The stream to get a resource for
27 *
28 * @return resource
29 *
30 * @throws \InvalidArgumentException if stream is not readable or writable
31 */
32 public static function getResource(StreamInterface $stream)
33 {
34 self::register();
35
36 if ($stream->isReadable()) {
37 $mode = $stream->isWritable() ? 'r+' : 'r';
38 } elseif ($stream->isWritable()) {
39 $mode = 'w';
40 } else {
41 throw new \InvalidArgumentException('The stream must be readable, '
42 . 'writable, or both.');
43 }
44
45 return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
46 }
47
48 /**
49 * Creates a stream context that can be used to open a stream as a php stream resource.
50 *
51 * @param StreamInterface $stream
52 *
53 * @return resource
54 */
55 public static function createStreamContext(StreamInterface $stream)
56 {
57 return stream_context_create([
58 'guzzle' => ['stream' => $stream]
59 ]);
60 }
61
62 /**
63 * Registers the stream wrapper if needed
64 */
65 public static function register()
66 {
67 if (!in_array('guzzle', stream_get_wrappers())) {
68 stream_wrapper_register('guzzle', __CLASS__);
69 }
70 }
71
72 public function stream_open($path, $mode, $options, &$opened_path)
73 {
74 $options = stream_context_get_options($this->context);
75
76 if (!isset($options['guzzle']['stream'])) {
77 return false;
78 }
79
80 $this->mode = $mode;
81 $this->stream = $options['guzzle']['stream'];
82
83 return true;
84 }
85
86 public function stream_read($count)
87 {
88 return $this->stream->read($count);
89 }
90
91 public function stream_write($data)
92 {
93 return (int) $this->stream->write($data);
94 }
95
96 public function stream_tell()
97 {
98 return $this->stream->tell();
99 }
100
101 public function stream_eof()
102 {
103 return $this->stream->eof();
104 }
105
106 public function stream_seek($offset, $whence)
107 {
108 $this->stream->seek($offset, $whence);
109
110 return true;
111 }
112
113 public function stream_cast($cast_as)
114 {
115 $stream = clone($this->stream);
116
117 return $stream->detach();
118 }
119
120 public function stream_stat()
121 {
122 static $modeMap = [
123 'r' => 33060,
124 'rb' => 33060,
125 'r+' => 33206,
126 'w' => 33188,
127 'wb' => 33188
128 ];
129
130 return [
131 'dev' => 0,
132 'ino' => 0,
133 'mode' => $modeMap[$this->mode],
134 'nlink' => 0,
135 'uid' => 0,
136 'gid' => 0,
137 'rdev' => 0,
138 'size' => $this->stream->getSize() ?: 0,
139 'atime' => 0,
140 'mtime' => 0,
141 'ctime' => 0,
142 'blksize' => 0,
143 'blocks' => 0
144 ];
145 }
146
147 public function url_stat($path, $flags)
148 {
149 return [
150 'dev' => 0,
151 'ino' => 0,
152 'mode' => 0,
153 'nlink' => 0,
154 'uid' => 0,
155 'gid' => 0,
156 'rdev' => 0,
157 'size' => 0,
158 'atime' => 0,
159 'mtime' => 0,
160 'ctime' => 0,
161 'blksize' => 0,
162 'blocks' => 0
163 ];
164 }
165 }
166