Logger::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace DH\DoctrineAuditBundle\DBAL;
4
5
use Doctrine\DBAL\Logging\SQLLogger;
6
7
class Logger implements SQLLogger
8
{
9
    /**
10
     * @var callable
11
     */
12
    private $flusher;
13
14
    public function __construct(callable $flusher)
15
    {
16
        $this->flusher = $flusher;
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function startQuery($sql, ?array $params = null, ?array $types = null): void
23
    {
24
        // right before commit insert all audit entries
25
        if ('"COMMIT"' === $sql) {
26
            \call_user_func($this->flusher);
27
        }
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function stopQuery(): void
34
    {
35
    }
36
}
37