Completed
Push — master ( fba866...b10a48 )
by Ori
03:03
created

BaseDataSource   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A open() 0 3 1
getNextLine() 0 1 ?
isEof() 0 1 ?
A close() 0 4 1
A getOption() 0 8 2
1
<?php
2
namespace frictionlessdata\tableschema\DataSources;
3
4
/**
5
 * base data source class with some common functionality
6
 */
7
abstract class BaseDataSource implements DataSourceInterface
8
{
9
    public function __construct($dataSource, $options=null)
10
    {
11
        $this->dataSource = $dataSource;
12
        $this->options = empty($options) ? (object)[] : $options;
13
    }
14
15
    public function open() {
16
17
    }
18
19
    abstract public function getNextLine();
20
    abstract public function isEof();
21
22
    public function close()
23
    {
24
25
    }
26
27
    protected $dataSource;
28
    protected $options;
29
30
    protected function getOption($name, $default=null)
31
    {
32
        if (isset($this->options->{$name})) {
33
            return $this->options->{$name};
34
        } else {
35
            return $default;
36
        }
37
    }
38
}
39