Logger   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A startQuery() 0 5 2
A __construct() 0 3 1
A stopQuery() 0 2 1
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