CsvFileIterator   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __destruct() 0 3 1
A rewind() 0 5 1
A valid() 0 3 1
A key() 0 3 1
A current() 0 3 1
A next() 0 4 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
}