CsvFileIterator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace EasyBanglaDateTests\Utils;
4
5
class CsvFileIterator implements \Iterator {
6
    protected $file;
7
    protected $key = 0;
8
    protected $current;
9
10
    public function __construct($file) {
11
        $this->file = fopen($file, 'r');
12
    }
13
14
    public function __destruct() {
15
        fclose($this->file);
16
    }
17
18
    public function rewind() {
19
        rewind($this->file);
20
        $this->current = fgetcsv($this->file);
21
        $this->key = 0;
22
    }
23
24
    public function valid() {
25
        return !feof($this->file);
26
    }
27
28
    public function key() {
29
        return $this->key;
30
    }
31
32
    public function current() {
33
        return $this->current;
34
    }
35
36
    public function next() {
37
        $this->current = fgetcsv($this->file);
38
        $this->key++;
39
    }
40
}