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

TransactionCollection::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
}