Code Duplication    Length = 19-19 lines in 2 locations

src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php 1 location

@@ 202-220 (lines=19) @@
199
     *
200
     * @throws \PhpOffice\PhpSpreadsheet\Exception
201
     */
202
    protected function adjustForExistingOnlyRange()
203
    {
204
        if ($this->onlyExistingCells) {
205
            while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) &&
206
                ($this->startRow <= $this->endRow)) {
207
                ++$this->startRow;
208
            }
209
            if ($this->startRow > $this->endRow) {
210
                throw new \PhpOffice\PhpSpreadsheet\Exception('No cells exist within the specified range');
211
            }
212
            while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) &&
213
                ($this->endRow >= $this->startRow)) {
214
                --$this->endRow;
215
            }
216
            if ($this->endRow < $this->startRow) {
217
                throw new \PhpOffice\PhpSpreadsheet\Exception('No cells exist within the specified range');
218
            }
219
        }
220
    }
221
}
222

src/PhpSpreadsheet/Worksheet/RowCellIterator.php 1 location

@@ 211-229 (lines=19) @@
208
     *
209
     * @throws \PhpOffice\PhpSpreadsheet\Exception
210
     */
211
    protected function adjustForExistingOnlyRange()
212
    {
213
        if ($this->onlyExistingCells) {
214
            while ((!$this->subject->cellExistsByColumnAndRow($this->startColumn, $this->rowIndex)) &&
215
                ($this->startColumn <= $this->endColumn)) {
216
                ++$this->startColumn;
217
            }
218
            if ($this->startColumn > $this->endColumn) {
219
                throw new \PhpOffice\PhpSpreadsheet\Exception('No cells exist within the specified range');
220
            }
221
            while ((!$this->subject->cellExistsByColumnAndRow($this->endColumn, $this->rowIndex)) &&
222
                ($this->endColumn >= $this->startColumn)) {
223
                --$this->endColumn;
224
            }
225
            if ($this->endColumn < $this->startColumn) {
226
                throw new \PhpOffice\PhpSpreadsheet\Exception('No cells exist within the specified range');
227
            }
228
        }
229
    }
230
}
231