DHDriver   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resetDHFlusherList() 0 3 1
A connect() 0 5 1
A addDHFlusher() 0 3 1
A getFlusherList() 0 3 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 as DriverInterface;
8
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
9
10
/**
11
 * @interal
12
 */
13
final class DHDriver extends AbstractDriverMiddleware
14
{
15
    private DriverInterface $driver;
16
17
    /** @var array<callable> */
18
    private array $flusherList = [];
19
20
    public function __construct(DriverInterface $driver)
21
    {
22
        parent::__construct($driver);
23
        $this->driver = $driver;
24
    }
25
26
    public function connect(array $params): DHConnection
27
    {
28
        return new DHConnection(
29
            $this->driver->connect($params),
30
            $this
31
        );
32
    }
33
34
    public function addDHFlusher(callable $flusher): void
35
    {
36
        $this->flusherList[] = $flusher;
37
    }
38
39
    public function resetDHFlusherList(): void
40
    {
41
        $this->flusherList = [];
42
    }
43
44
    public function getFlusherList(): array
45
    {
46
        return $this->flusherList;
47
    }
48
}
49