/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Collection/Iterator
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Collection/Iterator/InsertIterator.php (3848B)
*/
protected $_path;
/**
* The property name to which values will be assigned
*
* @var string
*/
protected $_target;
/**
* Constructs a new collection that will dynamically add properties to it out of
* the values found in $values.
*
* @param iterable $into The target collection to which the values will
* be inserted at the specified path.
* @param string $path A dot separated list of properties that need to be traversed
* to insert the value into the target collection.
* @param iterable $values The source collection from which the values will
* be inserted at the specified path.
*/
public function __construct(iterable $into, string $path, iterable $values)
{
parent::__construct($into);
if (!($values instanceof Collection)) {
$values = new Collection($values);
}
$path = explode('.', $path);
$target = array_pop($path);
$this->_path = $path;
$this->_target = $target;
$this->_values = $values;
}
/**
* Advances the cursor to the next record
*
* @return void
*/
public function next(): void
{
parent::next();
if ($this->_validValues) {
$this->_values->next();
}
$this->_validValues = $this->_values->valid();
}
/**
* Returns the current element in the target collection after inserting
* the value from the source collection into the specified path.
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{
$row = parent::current();
if (!$this->_validValues) {
return $row;
}
$pointer = &$row;
foreach ($this->_path as $step) {
if (!isset($pointer[$step])) {
return $row;
}
$pointer = &$pointer[$step];
}
$pointer[$this->_target] = $this->_values->current();
return $row;
}
/**
* Resets the collection pointer.
*
* @return void
*/
public function rewind(): void
{
parent::rewind();
$this->_values->rewind();
$this->_validValues = $this->_values->valid();
}
}