Passed
Push — master ( 0b19e6...20f332 )
by Mike
03:05
created

TransactionCollection   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 78.95%

Importance

Changes 0
Metric Value
dl 0
loc 65
ccs 15
cts 19
cp 0.7895
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A count() 0 3 1
A clear() 0 3 1
A key() 0 3 1
A valid() 0 3 1
A add() 0 3 1
A current() 0 3 1
A next() 0 3 1
A rewind() 0 3 1
1
<?php
2
3
namespace Xervice\Redis\Transaction;
4
5
class TransactionCollection implements \Iterator, \Countable
6
{
7
    /**
8
     * @var \Xervice\Redis\Transaction\TransactionInterface[]
9
     */
10
    private $collection = [];
11
12
    /**
13
     * @var int
14
     */
15
    private $position;
16
17
    /**
18
     * @param \Xervice\Redis\Transaction\TransactionInterface $validator
19
     */
20 1
    public function add(TransactionInterface $validator)
21
    {
22 1
        $this->collection[] = $validator;
23 1
    }
24
25
    /**
26
     * @return \Xervice\Redis\Transaction\TransactionInterface
27
     */
28 1
    public function current()
29
    {
30 1
        return $this->collection[$this->position];
31
    }
32
33 1
    public function next()
34
    {
35 1
        $this->position++;
36 1
    }
37
38
    /**
39
     * @return int
40
     */
41
    public function key()
42
    {
43
        return $this->position;
44
    }
45
46
    /**
47
     * @return bool
48
     */
49 1
    public function valid()
50
    {
51 1
        return isset($this->collection[$this->position]);
52
    }
53
54 1
    public function rewind()
55
    {
56 1
        $this->position = 0;
57 1
    }
58
59
    /**
60
     * @return int
61
     */
62
    public function count()
63
    {
64
        return \count($this->collection);
65
    }
66
67 1
    public function clear()
68
    {
69 1
        $this->collection = [];
70
    }
71
}