/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/ReplaceIterator.php (2878B)
_callback = $callback;
parent::__construct($items);
$this->_innerIterator = $this->getInnerIterator();
}
/**
* Returns the value returned by the callback after passing the current value in
* the iteration
*
* @return mixed
*/
public function current()
{
$callback = $this->_callback;
return $callback(parent::current(), $this->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->_callback;
$res = [];
foreach ($iterator as $k => $v) {
$res[$k] = $callback($v, $k, $iterator);
}
return new ArrayIterator($res);
}
}