Collections\Collection::insertRange PHP Method

insertRange() public method

public insertRange ( $index, array $items )
$items array
    public function insertRange($index, array $items)
    {
        $this->validateIndex($index);
        $this->validateItems($items, $this->type);
        //To work with negative index, get the positive relation to 0 index
        $index < 0 && ($index = $this->count() + $index + 1);
        $partA = array_slice($this->items, 0, $index);
        $partB = array_slice($this->items, $index, count($this->items));
        $items1 = array_merge($partA, $items);
        $items1 = array_merge($items1, $partB);
        $col = new static($this->type);
        $col->setItemsFromTrustedSource($items1);
        return $col;
    }