gielfeldt/iterators

View on GitHub
src/IntersectIterator.php

Summary

Maintainability
A
35 mins
Test Coverage
<?php

namespace Gielfeldt\Iterators;

class IntersectIterator extends DiffIterator
{
    public function accept()
    {
        $found = 0;
        foreach ($this->iterators as $iterator) {
            foreach ($iterator as $key => $value) {
                if (($this->callback)($this->getInnerIterator(), $key, $value)) {
                    $found++;
                    continue;
                }
            }
        }
        return $found == count($this->iterators);
    }
}