NativeDataSource   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 34
c 0
b 0
f 0
rs 10
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A open() 0 4 1
A getNextLine() 0 4 1
A isEof() 0 4 1
A save() 0 4 1
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