class-filesystemwritestream.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WordPress\Filesystem\ByteStream; |
| 4 | |
| 5 | use WordPress\ByteStream\WriteStream\ByteWriteStream; |
| 6 | use WordPress\Filesystem\Mixin\Interfaces\InternalizedWriteStream; |
| 7 | |
| 8 | class FilesystemWriteStream implements ByteWriteStream { |
| 9 | |
| 10 | /** |
| 11 | * @var InternalizedWriteStream |
| 12 | */ |
| 13 | protected $filesystem; |
| 14 | |
| 15 | /** |
| 16 | * @var int |
| 17 | */ |
| 18 | protected $stream_id; |
| 19 | |
| 20 | public function __construct( InternalizedWriteStream $filesystem, int $stream_id ) { |
| 21 | $this->filesystem = $filesystem; |
| 22 | $this->stream_id = $stream_id; |
| 23 | } |
| 24 | |
| 25 | public function append_bytes( $data ): void { |
| 26 | $this->filesystem->write_stream_append_bytes( $this->stream_id, $data ); |
| 27 | } |
| 28 | |
| 29 | public function close_writing(): void { |
| 30 | $this->filesystem->write_stream_close( $this->stream_id ); |
| 31 | } |
| 32 | } |
| 33 |