DHConnection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A commit() 0 10 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
30
        $this->DHDriver->resetDHFlusherList();
31
32
        return parent::commit();
33
    }
34
35
    public function rollBack(): bool
36
    {
37
        $this->DHDriver->resetDHFlusherList();
38
39
        return parent::rollBack();
40
    }
41
}
42