TransactionManager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 3 1
A begin() 0 3 1
A commit() 0 3 1
A rollback() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Common\Doctrine\Dbal;
6
7
use Closure;
8
use Damax\Common\Domain\Transaction\TransactionManager as TransactionManagerInterface;
9
use Doctrine\DBAL\Connection;
10
11
final class TransactionManager implements TransactionManagerInterface
12
{
13
    private $db;
14
15
    public function __construct(Connection $db)
16
    {
17
        $this->db = $db;
18
    }
19
20
    public function begin(): void
21
    {
22
        $this->db->beginTransaction();
23
    }
24
25
    public function commit(): void
26
    {
27
        $this->db->commit();
28
    }
29
30
    public function rollback(): void
31
    {
32
        $this->db->rollBack();
33
    }
34
35
    public function run(Closure $fn): void
36
    {
37
        $this->db->transactional($fn);
38
    }
39
}
40