1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Core; |
4: | |
5: | use Salient\Contract\Polyfill\StreamWrapper; |
6: | use Salient\Utility\Arr; |
7: | |
8: | |
9: | |
10: | |
11: | abstract class AbstractStreamWrapper extends StreamWrapper |
12: | { |
13: | |
14: | protected const DEFAULT_STAT = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1]; |
15: | |
16: | |
17: | |
18: | private const STAT_KEYS = ['dev', 'ino', 'mode', 'nlink', 'uid', 'gid', 'rdev', 'size', 'atime', 'mtime', 'ctime', 'blksize', 'blocks']; |
19: | |
20: | |
21: | |
22: | |
23: | public function __construct() {} |
24: | |
25: | |
26: | |
27: | |
28: | public function stream_metadata(string $path, int $option, $value): bool |
29: | { |
30: | return false; |
31: | } |
32: | |
33: | |
34: | |
35: | |
36: | public function stream_set_option(int $option, int $arg1, int $arg2): bool |
37: | { |
38: | return false; |
39: | } |
40: | |
41: | |
42: | |
43: | |
44: | public function stream_stat() |
45: | { |
46: | return $this->buildStat(static::DEFAULT_STAT); |
47: | } |
48: | |
49: | |
50: | |
51: | |
52: | public function url_stat(string $path, int $flags) |
53: | { |
54: | return $this->buildStat(static::DEFAULT_STAT); |
55: | } |
56: | |
57: | |
58: | |
59: | |
60: | |
61: | protected function buildStat(array $stat): array |
62: | { |
63: | return $stat + Arr::combine(self::STAT_KEYS, $stat); |
64: | } |
65: | } |
66: | |