Passed
Push — master ( 240c83...03f39b )
by Mathias
06:41
created

TestIterator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 11
dl 0
loc 31
rs 10
c 1
b 0
f 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A key() 0 2 1
A rewind() 0 2 1
A current() 0 2 1
A __construct() 0 3 1
A next() 0 2 1
A valid() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yawik\Migration\Tests;
6
7
use Iterator;
8
9
class TestIterator implements Iterator
10
{
11
    private int $position = 0;
12
13
    private array $data = array(
14
        "user.images",
15
    );
16
17
    public function __construct(array $data) {
18
        $this->data = $data;
19
        $this->position = 0;
20
    }
21
22
    public function rewind() {
23
        $this->position = 0;
24
    }
25
26
    public function current() {
27
        return $this->data[$this->position];
28
    }
29
30
    public function key() {
31
        return $this->position;
32
    }
33
34
    public function next() {
35
        ++$this->position;
36
    }
37
38
    public function valid() {
39
        return isset($this->data[$this->position]);
40
    }
41
}