Code Duplication    Length = 17-19 lines in 2 locations

src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php 1 location

@@ 182-200 (lines=19) @@
179
     *
180
     * @throws PhpSpreadsheetException
181
     */
182
    protected function adjustForExistingOnlyRange()
183
    {
184
        if ($this->onlyExistingCells) {
185
            while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) &&
186
                ($this->startRow <= $this->endRow)) {
187
                ++$this->startRow;
188
            }
189
            if ($this->startRow > $this->endRow) {
190
                throw new PhpSpreadsheetException('No cells exist within the specified range');
191
            }
192
            while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) &&
193
                ($this->endRow >= $this->startRow)) {
194
                --$this->endRow;
195
            }
196
            if ($this->endRow < $this->startRow) {
197
                throw new PhpSpreadsheetException('No cells exist within the specified range');
198
            }
199
        }
200
    }
201
}
202

src/PhpSpreadsheet/Worksheet/RowCellIterator.php 1 location

@@ 181-197 (lines=17) @@
178
     *
179
     * @throws PhpSpreadsheetException
180
     */
181
    protected function adjustForExistingOnlyRange()
182
    {
183
        if ($this->onlyExistingCells) {
184
            while ((!$this->worksheet->cellExistsByColumnAndRow($this->startColumnIndex, $this->rowIndex)) && ($this->startColumnIndex <= $this->endColumnIndex)) {
185
                ++$this->startColumnIndex;
186
            }
187
            if ($this->startColumnIndex > $this->endColumnIndex) {
188
                throw new PhpSpreadsheetException('No cells exist within the specified range');
189
            }
190
            while ((!$this->worksheet->cellExistsByColumnAndRow($this->endColumnIndex, $this->rowIndex)) && ($this->endColumnIndex >= $this->startColumnIndex)) {
191
                --$this->endColumnIndex;
192
            }
193
            if ($this->endColumnIndex < $this->startColumnIndex) {
194
                throw new PhpSpreadsheetException('No cells exist within the specified range');
195
            }
196
        }
197
    }
198
}
199