Code Duplication    Length = 27-27 lines in 3 locations

samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php 1 location

@@ 14-40 (lines=27) @@
11
$inputFileName = __DIR__ . '/sampleData/example2.xls';
12
13
/**  Define a Read Filter class implementing IReadFilter  */
14
class ChunkReadFilter implements IReadFilter
15
{
16
    private $_startRow = 0;
17
    private $_endRow = 0;
18
19
    /**
20
     * We expect a list of the rows that we want to read to be passed into the constructor.
21
     *
22
     * @param mixed $startRow
23
     * @param mixed $chunkSize
24
     */
25
    public function __construct($startRow, $chunkSize)
26
    {
27
        $this->_startRow = $startRow;
28
        $this->_endRow = $startRow + $chunkSize;
29
    }
30
31
    public function readCell($column, $row, $worksheetName = '')
32
    {
33
        //  Only read the heading row, and the rows that were configured in the constructor
34
        if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
35
            return true;
36
        }
37
38
        return false;
39
    }
40
}
41
42
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
43
/*  Create a new Reader of the type defined in $inputFileType  * */

samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php 1 location

@@ 14-40 (lines=27) @@
11
$inputFileName = __DIR__ . '/sampleData/example2.xls';
12
13
/**  Define a Read Filter class implementing IReadFilter  */
14
class ChunkReadFilter implements IReadFilter
15
{
16
    private $_startRow = 0;
17
    private $_endRow = 0;
18
19
    /**
20
     * Set the list of rows that we want to read.
21
     *
22
     * @param mixed $startRow
23
     * @param mixed $chunkSize
24
     */
25
    public function setRows($startRow, $chunkSize)
26
    {
27
        $this->_startRow = $startRow;
28
        $this->_endRow = $startRow + $chunkSize;
29
    }
30
31
    public function readCell($column, $row, $worksheetName = '')
32
    {
33
        //  Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
34
        if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
35
            return true;
36
        }
37
38
        return false;
39
    }
40
}
41
42
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
43
/*  Create a new Reader of the type defined in $inputFileType  * */

samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php 1 location

@@ 15-41 (lines=27) @@
12
$inputFileName = __DIR__ . '/sampleData/example2.csv';
13
14
/**  Define a Read Filter class implementing IReadFilter  */
15
class ChunkReadFilter implements IReadFilter
16
{
17
    private $_startRow = 0;
18
    private $_endRow = 0;
19
20
    /**
21
     * Set the list of rows that we want to read.
22
     *
23
     * @param mixed $startRow
24
     * @param mixed $chunkSize
25
     */
26
    public function setRows($startRow, $chunkSize)
27
    {
28
        $this->_startRow = $startRow;
29
        $this->_endRow = $startRow + $chunkSize;
30
    }
31
32
    public function readCell($column, $row, $worksheetName = '')
33
    {
34
        //  Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
35
        if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
36
            return true;
37
        }
38
39
        return false;
40
    }
41
}
42
43
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType);
44
/*  Create a new Reader of the type defined in $inputFileType  * */