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