TransactionCollection   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 78.95%

Importance

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