NativeDataSource::getNextLine()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace frictionlessdata\tableschema\DataSources;
4
5
use frictionlessdata\tableschema\Exceptions\DataSourceException;
6
7
/**
8
 * the data source parameter provided to the constructor should be an array of values
9
 * those values are then returned on each iteration.
10
 */
11
class NativeDataSource extends BaseDataSource
12
{
13
    public function open()
14
    {
15
        // no opening is needed for native data source
16
    }
17
18
    /**
19
     * @return array
20
     *
21
     * @throws DataSourceException
22
     */
23
    public function getNextLine()
24
    {
25
        return $this->dataSource[$this->curRowNum++];
26
    }
27
28
    /**
29
     * @return bool
30
     *
31
     * @throws DataSourceException
32
     */
33
    public function isEof()
34
    {
35
        return $this->curRowNum >= count($this->dataSource);
36
    }
37
38
    public function save($output)
39
    {
40
        // no point in saving for native data source
41
    }
42
43
    protected $curRowNum = 0;
44
}
45