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

DHDriver   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A resetDHFlusherList() 0 3 1
A __construct() 0 4 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
    /**
27
     * {@inheritDoc}
28
     */
29
    public function connect(array $params)
30
    {
31
        return new DHConnection(
32
            $this->driver->connect($params),
33
            $this
34
        );
35
    }
36
37
    public function addDHFlusher(callable $flusher): void
38
    {
39
        $this->flusherList[] = $flusher;
40
    }
41
42
    public function resetDHFlusherList(): void
43
    {
44
        $this->flusherList = [];
45
    }
46
47
    public function getFlusherList(): array
48
    {
49
        return $this->flusherList;
50
    }
51
}
52