Passed
Pull Request — master (#123)
by
unknown
02:07
created

DHConnection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 2
b 0
f 0
dl 0
loc 26
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A commit() 0 9 2
A rollBack() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DH\Auditor\Provider\Doctrine\Auditing\Logger\Middleware;
6
7
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
8
use Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware;
9
10
/**
11
 * @interal
12
 */
13
final class DHConnection extends AbstractConnectionMiddleware
14
{
15
    private DHDriver $DHDriver;
16
17
    public function __construct(ConnectionInterface $connection, DHDriver $DHDriver)
18
    {
19
        parent::__construct($connection);
20
        $this->DHDriver = $DHDriver;
21
    }
22
23
    public function commit(): bool
24
    {
25
        $flusherList = $this->DHDriver->getFlusherList();
26
        foreach ($flusherList as $flusher) {
27
            ($flusher)();
28
        }
29
        $this->DHDriver->resetDHFlusherList();
30
31
        return parent::commit();
32
    }
33
34
    public function rollBack(): bool
35
    {
36
        $this->DHDriver->resetDHFlusherList();
37
38
        return parent::rollBack();
39
    }
40
}
41