TransactionCollection::clear()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 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
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