nozavroni / csvelte

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

Readable/Writable/Seekable should be compatible with SplFileObject #96

Closed nozavroni closed 8 years ago

nozavroni commented 8 years ago

It would be really convenient if somebody could simply pass a SplFileObject into the Reader/Writer classes. In order to make this possible, I need to adjust the Readable, Writable, and Seekable interfaces.

From issue #77

The more I think about this the more I think extending SplFileObject the way I am is a bad idea. I think a better way to go would be to rewrite the Writable interface to fit with SplFileObject so that any SplFileObject can be passed to the Reader/Writer as-is. I could maybe write specialized versions of them just for clarity and to restrict access to certain methods or whatever, but you wouldn't have to use my file object(s). So basically I would just change the Readable interface to...

Readable

interface Readable 
{
    public function fgets() (or getCurrentLine());
    public function fread($length);
    public function eof();
    public function rewind();
}

Writable

interface Writable 
{
    public function fwrite($string);
}

In fact I could probably still keep my CSVelte\IO\File object for convenience if I want it. But I just need ot adjust the interfaces. Probably want to add this one too:

Seekable

interface Seekable 
{
    public function fseek($pos);
}
  • [x] Create refactor/96 branch
  • [ ] Adjust Readable interface
  • [ ] Make changes in Reader to use new methods
  • [ ] Either write new or adjust existing CSVelte\Input* classes (see issue #97)
  • [ ] Update any relevant unit tests
  • [ ] Update new CSVelte\IO\File class (or delete it)
  • [ ] Update unit tests for this class
  • [ ] Merge branch back into v0.2
  • [ ] Delete refactor branch
  • [ ] Update documentation
nozavroni commented 8 years ago

Change these back to what they were... I won't be able to accept SplFileObject the way I wanted.

nozavroni commented 8 years ago

Decided not to do this