src/AnyDataset.php
public function insertRowBefore($rowNumber, $row = null)
    {
        if ($rowNumber > count($this->collection)) {
            $this->appendRow($row);
        } else {
            $singleRow = $row;
            if (!($row instanceof Row)) {
                $singleRow = new Row($row);
            }
            array_splice($this->collection, $rowNumber, 0, '');
            $this->collection[$rowNumber] = $singleRow;
        }
    }
public function insertRowBefore($rowNumber, $row = null)
    {
        if ($rowNumber > count($this->collection)) {
            $this->appendRow($row);
        } else {
            $singleRow = $row;
            if (!($row instanceof Row)) {
                $singleRow = new Row($row);
            }
            array_splice($this->collection, $rowNumber, 0, '');
            $this->collection[$rowNumber] = $singleRow;
        }
    }
Insert one row before specified position.

@param int $rowNumber
@param mixed $row
@throws \ByJG\Serializer\Exception\InvalidArgumentException