/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Collection/Iterator
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Collection/Iterator/StoppableIterator.php (3317B)
_condition = $condition;
parent::__construct($items);
$this->_innerIterator = $this->getInnerIterator();
}
/**
* Evaluates the condition and returns its result, this controls
* whether or not more results will be yielded.
*
* @return bool
*/
public function valid(): bool
{
if (!parent::valid()) {
return false;
}
$current = $this->current();
$key = $this->key();
$condition = $this->_condition;
return !$condition($current, $key, $this->_innerIterator);
}
/**
* @inheritDoc
*/
public function unwrap(): Traversable
{
$iterator = $this->_innerIterator;
if ($iterator instanceof CollectionInterface) {
$iterator = $iterator->unwrap();
}
if (get_class($iterator) !== ArrayIterator::class) {
return $this;
}
// ArrayIterator can be traversed strictly.
// Let's do that for performance gains
$callback = $this->_condition;
$res = [];
foreach ($iterator as $k => $v) {
if ($callback($v, $k, $iterator)) {
break;
}
$res[$k] = $v;
}
return new ArrayIterator($res);
}
}