TransactionHandler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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