nozavroni / csvelte

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

Implement serialization magic methods #104

Open nozavroni opened 7 years ago

nozavroni commented 7 years ago

Might be useful to add __sleep and __wakeup methods to the dataset class. This way you could do something like:

<?php
$reader = (new Reader(new IO\Stream('./data/products.csv')))->addFilter(function($row) {
    if (isset($row['email'])) {
        return is_guy_cool($row['email']);
    }
    return false;
});
$dataset = (new DataSet())->import($reader);
$csv = serialize($dataset);

I don't know if that's exactly how it would work, but I can see that being useful for sure. Look into it. Maybe for v0.4?