1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Stream package. |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Serafim\Stream\Wrapper; |
13
|
|
|
|
14
|
|
|
use Serafim\Stream\Exception\StreamException; |
15
|
|
|
|
16
|
|
|
abstract class AbstractStreamWrapper implements StreamWrapperInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var resource |
20
|
|
|
*/ |
21
|
|
|
protected $resource; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @inheritdoc |
25
|
|
|
* @throws StreamException |
26
|
|
|
*/ |
27
|
|
|
public function stream_cast(int $castAs): void |
28
|
|
|
{ |
29
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_CAST); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $function |
34
|
|
|
* @param int $code |
35
|
|
|
* @return StreamException |
36
|
|
|
*/ |
37
|
|
|
protected function notAcceptable(string $function, int $code = 0): StreamException |
38
|
|
|
{ |
39
|
|
|
$error = \sprintf('%s->%s is not acceptable', static::class, $function); |
40
|
|
|
|
41
|
|
|
return new StreamException($error, $code); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @inheritdoc |
46
|
|
|
* @throws StreamException |
47
|
|
|
*/ |
48
|
|
|
public function stream_set_option(int $option, int $arg1, int $arg2): bool |
49
|
|
|
{ |
50
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_SET_OPTION); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritdoc |
55
|
|
|
* @throws StreamException |
56
|
|
|
*/ |
57
|
|
|
public function stream_metadata(string $path, int $option, int $value): bool |
58
|
|
|
{ |
59
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_METADATA); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @inheritdoc |
64
|
|
|
* @throws StreamException |
65
|
|
|
*/ |
66
|
|
|
public function unlink(string $path): bool |
67
|
|
|
{ |
68
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_UNLINK); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @inheritdoc |
73
|
|
|
* @throws StreamException |
74
|
|
|
*/ |
75
|
|
|
public function rename(string $from, string $to): bool |
76
|
|
|
{ |
77
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_RENAME); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @inheritdoc |
82
|
|
|
* @throws StreamException |
83
|
|
|
*/ |
84
|
|
|
public function mkdir(string $path, int $mode, int $options): bool |
85
|
|
|
{ |
86
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_MKDIR); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @inheritdoc |
91
|
|
|
* @throws StreamException |
92
|
|
|
*/ |
93
|
|
|
public function rmdir(string $path, int $options): bool |
94
|
|
|
{ |
95
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_RMDIR); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @inheritdoc |
100
|
|
|
* @throws StreamException |
101
|
|
|
*/ |
102
|
|
|
public function dir_opendir(string $path, int $options): bool |
103
|
|
|
{ |
104
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_DIR_OPENDIR); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @inheritdoc |
109
|
|
|
* @throws StreamException |
110
|
|
|
*/ |
111
|
|
|
public function dir_readdir(): void |
112
|
|
|
{ |
113
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_DIR_READDIR); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @inheritdoc |
118
|
|
|
* @throws StreamException |
119
|
|
|
*/ |
120
|
|
|
public function dir_rewinddir(): bool |
121
|
|
|
{ |
122
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_DIR_REWINDDIR); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @inheritdoc |
127
|
|
|
* @throws StreamException |
128
|
|
|
*/ |
129
|
|
|
public function dir_closedir(): bool |
130
|
|
|
{ |
131
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_DIR_CLOSEDIR); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @inheritdoc |
136
|
|
|
* @throws StreamException |
137
|
|
|
*/ |
138
|
|
|
public function stream_lock(int $operation): bool |
139
|
|
|
{ |
140
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_LOCK); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @inheritdoc |
145
|
|
|
* @throws StreamException |
146
|
|
|
*/ |
147
|
|
|
public function url_stat(string $path, int $flags): array |
148
|
|
|
{ |
149
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_URL_STAT); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @inheritdoc |
154
|
|
|
* @throws StreamException |
155
|
|
|
*/ |
156
|
|
|
public function stream_open(string $uri, string $mode, int $options, &$openedPath): bool |
157
|
|
|
{ |
158
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_OPEN); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @inheritdoc |
163
|
|
|
* @throws StreamException |
164
|
|
|
*/ |
165
|
|
|
public function stream_read(int $length): string |
166
|
|
|
{ |
167
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_READ); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @inheritdoc |
172
|
|
|
* @throws StreamException |
173
|
|
|
*/ |
174
|
|
|
public function stream_eof(): bool |
175
|
|
|
{ |
176
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_EOF); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @inheritdoc |
181
|
|
|
* @throws StreamException |
182
|
|
|
*/ |
183
|
|
|
public function stream_stat(): array |
184
|
|
|
{ |
185
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_URL_STAT); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @inheritdoc |
190
|
|
|
* @throws StreamException |
191
|
|
|
*/ |
192
|
|
|
public function stream_close(): void |
193
|
|
|
{ |
194
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_CLOSE); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* @inheritdoc |
199
|
|
|
* @throws StreamException |
200
|
|
|
*/ |
201
|
|
|
public function stream_tell(): int |
202
|
|
|
{ |
203
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_TELL); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @inheritdoc |
208
|
|
|
* @throws StreamException |
209
|
|
|
*/ |
210
|
|
|
public function stream_seek(int $offset, int $whence = SEEK_SET): bool |
211
|
|
|
{ |
212
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_SEEK); |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @inheritdoc |
217
|
|
|
* @throws StreamException |
218
|
|
|
*/ |
219
|
|
|
public function stream_flush(): bool |
220
|
|
|
{ |
221
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_FLUSH); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @inheritdoc |
226
|
|
|
* @throws StreamException |
227
|
|
|
*/ |
228
|
|
|
public function stream_write(string $data): int |
229
|
|
|
{ |
230
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_WRITE); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @inheritdoc |
235
|
|
|
* @throws StreamException |
236
|
|
|
*/ |
237
|
|
|
public function stream_truncate(int $size): bool |
238
|
|
|
{ |
239
|
|
|
throw $this->notAcceptable(__FUNCTION__, StreamException::CODE_STREAM_TRUNCATE); |
240
|
|
|
} |
241
|
|
|
} |
242
|
|
|
|