Closed nozavroni closed 7 years ago
I came up with an alternative solution for this... instead of creating an entirely new stream class, I abstracted the concept of a "stream resource" into a class of its own. the Stream class will now use it internally in place of simply using a php stream resource handle. Then the resource object will lazy-open instead of the stream. Let me demonstrate:
$res = (new CSVelte\IO\Resource('./data/products.csv'))
->setBaseMode('w')
->setIsPlus(true)
->setIsBinary(true);
echo $res->isConnected(); // false
$stream = Stream::open($res);
$stream->getResource()->isConnected(); // false
$stream->write('helloworld');
echo $stream->getResource()->isConnected(); true
Finished with the exception of documentation
Closing all issues that only need documentation.
Implement a lazy open stream class (or maybe just make it the default). What this means is that the stream resource isn't opened until an I/O operation is performed on it.