Code Duplication    Length = 17-19 lines in 2 locations

src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php 1 location

@@ 190-208 (lines=19) @@
187
     *
188
     * @throws PhpSpreadsheetException
189
     */
190
    protected function adjustForExistingOnlyRange()
191
    {
192
        if ($this->onlyExistingCells) {
193
            while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) &&
194
                ($this->startRow <= $this->endRow)) {
195
                ++$this->startRow;
196
            }
197
            if ($this->startRow > $this->endRow) {
198
                throw new PhpSpreadsheetException('No cells exist within the specified range');
199
            }
200
            while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) &&
201
                ($this->endRow >= $this->startRow)) {
202
                --$this->endRow;
203
            }
204
            if ($this->endRow < $this->startRow) {
205
                throw new PhpSpreadsheetException('No cells exist within the specified range');
206
            }
207
        }
208
    }
209
}
210

src/PhpSpreadsheet/Worksheet/RowCellIterator.php 1 location

@@ 189-205 (lines=17) @@
186
     *
187
     * @throws PhpSpreadsheetException
188
     */
189
    protected function adjustForExistingOnlyRange()
190
    {
191
        if ($this->onlyExistingCells) {
192
            while ((!$this->worksheet->cellExistsByColumnAndRow($this->startColumnIndex, $this->rowIndex)) && ($this->startColumnIndex <= $this->endColumnIndex)) {
193
                ++$this->startColumnIndex;
194
            }
195
            if ($this->startColumnIndex > $this->endColumnIndex) {
196
                throw new PhpSpreadsheetException('No cells exist within the specified range');
197
            }
198
            while ((!$this->worksheet->cellExistsByColumnAndRow($this->endColumnIndex, $this->rowIndex)) && ($this->endColumnIndex >= $this->startColumnIndex)) {
199
                --$this->endColumnIndex;
200
            }
201
            if ($this->endColumnIndex < $this->startColumnIndex) {
202
                throw new PhpSpreadsheetException('No cells exist within the specified range');
203
            }
204
        }
205
    }
206
}
207