nozavroni / csvelte

🕺🏻 CSV and Tabular Data library for PHP
http://phpcsv.com/
Other
6 stars 0 forks source link

Design stream decorator interface and functionality #136

Closed nozavroni closed 6 years ago

nozavroni commented 7 years ago

I need a way to decorate a stream with functionality. I don't want to use inheritance because it's too restrictive. I want to to keep a stream exactly the same, only add decorator objects to it at runtime to add (or remove) functionality. For example,

$stream = Stream::open($filename, 'r+b');
// pseudo-code
// name is not set in stone by any means (came off the top of head)
$stream->decorate(new Stream\MakeBuffered); 
// this would emulate the ability to seek on a non-seakable stream by reading
// it into a buffer and then seeking around on the buffer
$stream->decorate(new Stream\MakeSeekable);
nozavroni commented 6 years ago

This seems wildly out of the scope of this project.