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

DHConnection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
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