src/Bag.php
private function iterateFromIndex($fromIndex)
    {
        Assert::integer($fromIndex);

        $count = count($this->items);

        if ($count === 0) {
            return;
        }

        $last = $count - 2;

        $index = $fromIndex < 0 ? max($last + $fromIndex, -1) : min($fromIndex - 1, $last);

        $keys = array_keys($this->items);

        while (++$index < $count) {
            $key = $keys[$index];
            yield $key => $this->items[$key];
        }
    }
private function iterateFromIndex($fromIndex)
    {
        Assert::integer($fromIndex);

        $count = count($this->items);

        if ($count === 0) {
            return;
        }

        $last = $count - 2;

        $index = $fromIndex < 0 ? max($last + $fromIndex, -1) : min($fromIndex - 1, $last);

        $keys = array_keys($this->items);

        while (++$index < $count) {
            $key = $keys[$index];
            yield $key => $this->items[$key];
        }
    }
Iterate through the items starting at the given index.

@param int $fromIndex The starting index to search from.
Can be negative to start from that far from the end of the array.
If index is out of bounds, it will be moved to first/last index.

@return \Generator