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

TransactionHandler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 42
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A clearCollection() 0 3 1
A __construct() 0 3 1
A getTransactionArray() 0 9 2
A addToCollection() 0 3 1
1
<?php
2
3
4
namespace Xervice\Redis\Transaction;
5
6
7
8
use Xervice\DataProvider\DataProvider\AbstractDataProvider;
9
10
class TransactionHandler implements TransactionHandlerInterface
11
{
12
    /**
13
     * @var \Xervice\Redis\Transaction\TransactionCollection
14
     */
15
    private $collection;
16
17
    /**
18
     * TransactionHandler constructor.
19
     *
20
     * @param \Xervice\Redis\Transaction\TransactionCollection $collection
21
     */
22 1
    public function __construct(\Xervice\Redis\Transaction\TransactionCollection $collection)
23
    {
24 1
        $this->collection = $collection;
25 1
    }
26
27
    /**
28
     * @param \Xervice\Redis\Transaction\TransactionInterface $transaction
29
     */
30 1
    public function addToCollection(TransactionInterface $transaction)
31
    {
32 1
        $this->collection->add($transaction);
33 1
    }
34
35 1
    public function clearCollection()
36
    {
37 1
        $this->collection->clear();
38 1
    }
39
40
    /**
41
     * @return array
42
     */
43 1
    public function getTransactionArray() : array
44
    {
45 1
        $transactionList = [];
46
47 1
        foreach ($this->collection as $transaction) {
48 1
            $transactionList[$transaction->getKey()] = $transaction->getDataProvider();
49
        }
50
51 1
        return $transactionList;
52
    }
53
}