SplFileObject Countable
| From: | Sebastian Marek | Date: | Fri, 11 Mar 2011 23:22:04 +0000 |
| Subject: | SplFileObject Countable | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-51672@lists.php.net to get a copy of this message | ||
Hi,
I have recently used SplFileObject to work with files. I was lacking a bit
of functionality in there regarding counting number of lines in a given
file. Although I could just load contents of the file to an array and check
it size, I thought it would be nice to have SplFileObject Countable.
Here is an example implementation I made tonight that seems to work well -
https://gist.github.com/866767 . Is it something you
think would be worth
adding to the existing SplFileObject? Is the implementation any good? I
reused some of the existing logic to avoid breaking 'spl_filesystem_object'
internal integrity, but maybe it would make sense to make it work with the
stream itself.
If it's fine I can write some unit tests to cover this and then submit a
complete patch.
Regards
--
Sebastian Marek
proofek@gmail.com
Follow me online at:
Blog: http://criticallog.thornet.net/
Twitter: http://twitter.com/proofek
Linkedin: http://uk.linkedin.com/in/sebastianmarek
Ohloh: http://www.ohloh.net/accounts/proofek
<http://twitter.com/proofek>