ArrayInput   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 80
c 0
b 0
f 0
wmc 9
lcom 1
cbo 0
ccs 24
cts 24
cp 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 9 2
A add() 0 4 1
A reset() 0 4 1
A current() 0 4 1
A next() 0 4 1
A key() 0 4 1
A valid() 0 4 1
A rewind() 0 4 1
1
<?php
2
3
namespace Maketok\DataMigration\Input;
4
5
class ArrayInput implements InputResourceInterface, \Iterator
6
{
7
    /**
8
     * @var array
9
     */
10
    private $entries = [];
11
    /**
12
     * @var int
13
     */
14
    private $index = 0;
15
16
    /**
17
     * {@inheritdoc}
18
     */
19 2
    public function get()
20
    {
21 2
        if (!$this->valid()) {
22 2
            return false;
23
        }
24 2
        $current = $this->current();
25 2
        $this->next();
26 2
        return $current;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 3
    public function add(array $entity)
33
    {
34 3
        $this->entries[] = $entity;
35 3
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function reset()
41
    {
42 1
        $this->rewind();
43 1
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 2
    public function current()
49
    {
50 2
        return $this->entries[$this->index];
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 3
    public function next()
57
    {
58 3
        $this->index += 1;
59 3
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64 1
    public function key()
65
    {
66 1
        return $this->index;
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72 3
    public function valid()
73
    {
74 3
        return isset($this->entries[$this->index]);
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 1
    public function rewind()
81
    {
82 1
        $this->index = 0;
83 1
    }
84
}
85