morrisonlevi/Ardent

Filter Counter

olekukonko opened this issue · 5 comments

From https://github.com/morrisonlevi/Ardent/blob/master/src/Ardent/Iterator/FilteringIterator.php i notice the following code

    function count() {
        $i = 0;
        for ($this->rewind(); $this->valid(); $this->next()) {
            $i++;
        }
        return $i;
    }

Why just just implement FilteringIterator::$counter has integer and just do basic increment and decrements ?

Since writing this implementation I've found an SPL function that will replace the entire method body: iterator_count

See c70ca13 for the simplified implementation.

Agreed.

Commit 875de2c fixes this and adds minor documentation.